/*
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 { Base, BaseError, fromEnum, typeCast, runOn, delegateCombine, delegateRemove, markType, TypeRegistrar } from "igniteui-angular-core";
import { IDataChartToolbarProvider_$type } from "./IDataChartToolbarProvider";
import { SeriesViewer } from "./SeriesViewer";
import { ToolActionIconMenuInfo } from "igniteui-angular-core";
import { ToolActionGroupHeaderInfo } from "igniteui-angular-core";
import { ToolActionSeparatorInfo } from "igniteui-angular-core";
import { ToolActionLabelInfo } from "igniteui-angular-core";
import { ToolActionCheckboxInfo } from "igniteui-angular-core";
import { DeviceUtils } from "igniteui-angular-core";
import { Series } from "./Series";
import { ToolActionRadioInfo } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { ToolContextBindingInfo } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { XamDataChart } from "./XamDataChart";
import { Axis } from "./Axis";
import { BrushUtilCore } from "igniteui-angular-core";
import { ToolCommandArgument } from "igniteui-angular-core";
import { AutomaticSeriesRequest } from "./AutomaticSeriesRequest";
import { AxisStrokeSettings } from "./AxisStrokeSettings";
import { FastIterationDictionary$2 } from "igniteui-angular-core";
import { CaptureImageSettings } from "igniteui-angular-core";
import { isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
var DataChartToolbarProvider = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(DataChartToolbarProvider, _super);
    function DataChartToolbarProvider() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this._container = null;
        _this.k = null;
        _this.i = null;
        _this.g = null;
        _this.q = null;
        _this.r = new FastIterationDictionary$2(Axis.$, AxisStrokeSettings.$, 0);
        return _this;
    }
    Object.defineProperty(DataChartToolbarProvider.prototype, "container", {
        get: function () {
            return this._container;
        },
        set: function (a) {
            this._container = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DataChartToolbarProvider.prototype, "l", {
        get: function () {
            if (TypeRegistrar.isRegistered("HorizontalAnchoredCategorySeriesProxy")) {
                return TypeRegistrar.create("HorizontalAnchoredCategorySeriesProxy");
            }
            else {
                throw new BaseError(1, "category series module is not loaded, but is required.");
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DataChartToolbarProvider.prototype, "v", {
        get: function () {
            return (TypeRegistrar.isRegistered("HorizontalAnchoredCategorySeriesProxy"));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DataChartToolbarProvider.prototype, "j", {
        get: function () {
            if (TypeRegistrar.isRegistered("FinancialPriceSeriesProxy")) {
                return TypeRegistrar.create("FinancialPriceSeriesProxy");
            }
            else {
                throw new BaseError(1, "category series module is not loaded, but is required.");
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DataChartToolbarProvider.prototype, "u", {
        get: function () {
            return (TypeRegistrar.isRegistered("HorizontalAnchoredCategorySeriesProxy"));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DataChartToolbarProvider.prototype, "h", {
        get: function () {
            if (this.g == null) {
                if (TypeRegistrar.isRegistered("AnnotationLayerProxy")) {
                    this.g = TypeRegistrar.create("AnnotationLayerProxy");
                    this.g.container = this.container;
                }
                else {
                    throw new BaseError(1, "annotation layer module is not loaded, but is required.");
                }
            }
            return this.g;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DataChartToolbarProvider.prototype, "t", {
        get: function () {
            return (TypeRegistrar.isRegistered("AnnotationLayerProxy"));
        },
        enumerable: false,
        configurable: true
    });
    DataChartToolbarProvider.prototype.getDesiredToolbarActions = function (a) {
        var b = new ToolActionIconMenuInfo();
        b.name = "ZoomMenu";
        b.iconName = "zoomin";
        b.iconCollectionName = "ChartToolbarIcons";
        b.iconWidth = 24;
        b.iconHeight = 25;
        b.actions = this.e();
        var c = new ToolActionGroupHeaderInfo();
        c.name = "AnalyzeHeader";
        c.title = "Analyze";
        var d = new ToolActionSeparatorInfo();
        d.name = "AnalyzeHeaderSeparator";
        d.isGroupHeaderSeparator = true;
        var e = new ToolActionLabelInfo();
        e.name = "LinesMenu";
        e.title = "Lines";
        e.iconName = "analyze-lines";
        e.iconCollectionName = "ChartToolbarIcons";
        e.iconWidth = 24;
        e.iconHeight = 25;
        e.actions = this.a();
        var f = new ToolActionSeparatorInfo();
        f.name = "LinesMenuSeparator";
        var g = new ToolActionLabelInfo();
        g.name = "TrendsMenu";
        g.title = "Trends";
        g.iconName = "analyze-trends";
        g.iconCollectionName = "ChartToolbarIcons";
        g.iconWidth = 24;
        g.iconHeight = 25;
        g.actions = this.c();
        var h = new ToolActionGroupHeaderInfo();
        h.name = "HelpersHeader";
        h.title = "Helpers";
        var i = new ToolActionSeparatorInfo();
        i.name = "HelpersHeaderSeparator";
        i.isGroupHeaderSeparator = true;
        var j = new ToolActionCheckboxInfo();
        j.name = "SeriesAvg";
        j.title = "Series Average";
        j.iconName = "analyze-seriesavg";
        j.iconCollectionName = "ChartToolbarIcons";
        j.iconWidth = 24;
        j.iconHeight = 25;
        var k = new ToolActionSeparatorInfo();
        k.name = "SeriesAvgSeparator";
        var l = new ToolActionLabelInfo();
        l.name = "ValueLabelsMenu";
        l.title = "Value Labels";
        l.iconName = "analyze-valuelabels";
        l.iconCollectionName = "ChartToolbarIcons";
        l.actions = this.d(a);
        l.iconWidth = 24;
        l.iconHeight = 24;
        var m = new ToolActionSeparatorInfo();
        m.name = "HelpersSectionSeparator";
        m.size = DeviceUtils.g(10);
        var n = new ToolActionCheckboxInfo();
        n.name = "ShowGridlines";
        n.title = "Grid";
        n.iconName = "analyze-grid";
        n.iconCollectionName = "ChartToolbarIcons";
        n.iconWidth = 24;
        n.iconHeight = 25;
        var o = new ToolActionSeparatorInfo();
        o.name = "GridSeparator";
        var p = new ToolActionCheckboxInfo();
        p.name = "ShowCrosshairs";
        p.title = "Crosshairs";
        p.iconName = "analyze-crosshairs";
        p.iconCollectionName = "ChartToolbarIcons";
        p.iconWidth = 24;
        p.iconHeight = 25;
        var q = new ToolActionIconMenuInfo();
        q.name = "AnalyzeMenu";
        q.iconName = "analyze";
        q.iconCollectionName = "ChartToolbarIcons";
        q.iconWidth = 24;
        q.iconHeight = 25;
        q.actions = [c, d, e, f, g, h, i, j, k, l, m, n, o, p];
        var r = new ToolActionGroupHeaderInfo();
        r.name = "CopyHeader";
        r.title = "Copy...";
        var s = new ToolActionLabelInfo();
        s.name = "CopyAsImage";
        s.title = "As Image";
        s.iconName = "copy-image";
        s.iconCollectionName = "ChartToolbarIcons";
        s.closeOnExecute = true;
        var t = new ToolActionLabelInfo();
        t.name = "CopyAsTable";
        t.title = "Table Data";
        t.iconName = "copy-table";
        t.iconCollectionName = "ChartToolbarIcons";
        var u = new ToolActionIconMenuInfo();
        u.name = "CopyMenu";
        u.iconName = "copy";
        u.iconCollectionName = "ChartToolbarIcons";
        u.iconWidth = 24;
        u.iconHeight = 24;
        u.actions = [r, s];
        var v = [b, ((function () {
                var $ret = new ToolActionSeparatorInfo();
                $ret.name = "ZoomMenuSeparator";
                return $ret;
            })()), q, ((function () {
                var $ret = new ToolActionSeparatorInfo();
                $ret.name = "AnalyzeMenuSeparator";
                return $ret;
            })()), u];
        for (var w = 0; w < v.length; w++) {
            this.ba(a, v[w]);
        }
        return v;
    };
    DataChartToolbarProvider.prototype.ba = function (a, b) {
        var e_1, _a;
        if (b.actions != null && b.actions.length > 0) {
            for (var c = 0; c < b.actions.length; c++) {
                this.ba(a, b.actions[c]);
            }
        }
        switch (b.name) {
            case "ZoomReset":
                {
                    try {
                        for (var _b = __values(fromEnum(a.g4)), _c = _b.next(); !_c.done; _c = _b.next()) {
                            var d = _c.value;
                            d.setContextValue("ZoomResetIsDisabled", 5, Rect.l_op_Equality(a.x5, null) || a.x5.isEmpty || (a.x5.width >= 1 && a.x5.height >= 1));
                        }
                    }
                    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;
                        }
                    }
                }
                break;
            case "ShowValueLabels":
                {
                    var e = b;
                    var f = this.m(a);
                    e.isChecked = f != null && f._visibility == 0;
                }
                break;
            case "ShowLastValueLabel":
                {
                    var g = b;
                    var h = this.o(a);
                    g.isChecked = h != null && h._visibility == 0;
                }
                break;
            case "Linear":
                {
                    var i = b;
                    var j = a.ao(a);
                    i.isChecked = j.e(8);
                }
                break;
            case "Exponential":
                {
                    var k = b;
                    var l = a.ao(a);
                    k.isChecked = l.e(7);
                }
                break;
            case "Logarithmic":
                {
                    var m = b;
                    var n = a.ao(a);
                    m.isChecked = n.e(9);
                }
                break;
            case "NoTrends":
                {
                    var o = b;
                    var p = a.ao(a);
                    o.isChecked = !p.e(8) && !p.e(7) && !p.e(9);
                }
                break;
            case "MinValue":
                {
                    var q = b;
                    var r = this.p(a, 4);
                    q.isChecked = r != null && r._visibility == 0;
                }
                break;
            case "MaxValue":
                {
                    var s = b;
                    var t = this.p(a, 5);
                    s.isChecked = t != null && t._visibility == 0;
                }
                break;
            case "Average":
                {
                    var u = b;
                    var v = this.p(a, 6);
                    u.isChecked = v != null && v._visibility == 0;
                }
                break;
            case "ShowCrosshairs":
                {
                    var w = b;
                    var x = this.n(a);
                    w.isChecked = x != null && x._visibility == 0;
                }
                break;
            case "ShowGridlines":
                {
                    var y = b;
                    y.isChecked = this.s(a);
                }
                break;
            case "SeriesAvg":
                {
                    var z = b;
                    var aa = this.p(a, 3);
                    z.isChecked = aa != null && aa._visibility == 0;
                }
                break;
        }
    };
    DataChartToolbarProvider.prototype.e = function () {
        var a = new ToolActionGroupHeaderInfo();
        a.name = "ZoomHeader";
        a.title = "Zoom";
        var b = new ToolActionLabelInfo();
        b.name = "ZoomIn";
        b.iconName = "zoomin";
        b.iconCollectionName = "ChartToolbarIcons";
        b.iconWidth = 24;
        b.iconHeight = 25;
        b.title = "Zoom In";
        var c = new ToolActionLabelInfo();
        c.name = "ZoomOut";
        c.iconName = "zoomout";
        c.iconCollectionName = "ChartToolbarIcons";
        c.iconWidth = 24;
        c.iconHeight = 25;
        c.title = "Zoom Out";
        var d = new ToolActionLabelInfo();
        d.name = "ZoomReset";
        d.iconName = "reset";
        d.iconCollectionName = "ChartToolbarIcons";
        d.iconWidth = 24;
        d.iconHeight = 24;
        d.title = "Reset";
        d.contextBindings = [((function () {
                var $ret = new ToolContextBindingInfo();
                $ret.contextKey = "ZoomResetIsDisabled";
                $ret.propertyName = "IsDisabled";
                return $ret;
            })())];
        return [a, b, c, d];
    };
    DataChartToolbarProvider.prototype.a = function () {
        var a = new ToolActionGroupHeaderInfo();
        a.name = "LinesHeader";
        a.title = "Lines";
        var b = new ToolActionSeparatorInfo();
        b.isGroupHeaderSeparator = true;
        var c = new ToolActionCheckboxInfo();
        c.name = "MaxValue";
        c.title = "Max value";
        c.iconName = "analyze-lines-maxvalue";
        c.iconCollectionName = "ChartToolbarIcons";
        c.iconWidth = 24;
        c.iconHeight = 25;
        var d = new ToolActionCheckboxInfo();
        d.name = "MinValue";
        d.title = "Min value";
        d.iconName = "analyze-lines-minvalue";
        d.iconCollectionName = "ChartToolbarIcons";
        d.iconWidth = 24;
        d.iconHeight = 25;
        var e = new ToolActionCheckboxInfo();
        e.name = "Average";
        e.title = "Average";
        e.iconName = "analyze-seriesavg";
        e.iconCollectionName = "ChartToolbarIcons";
        e.iconWidth = 24;
        e.iconHeight = 25;
        return [a, b, c, d, e];
    };
    DataChartToolbarProvider.prototype.c = function () {
        var a = new ToolActionGroupHeaderInfo();
        a.name = "TrendsHeader";
        a.title = "Trends";
        var b = new ToolActionSeparatorInfo();
        b.name = "TrendsHeaderSeparator";
        b.isGroupHeaderSeparator = true;
        var c = new ToolActionRadioInfo();
        c.name = "Exponential";
        c.title = "Exponential";
        c.iconName = "analyze-trends-exp";
        c.iconCollectionName = "ChartToolbarIcons";
        c.channel = "trends";
        c.iconWidth = 24;
        c.iconHeight = 25;
        var d = new ToolActionRadioInfo();
        d.name = "Linear";
        d.title = "Linear";
        d.iconName = "analyze-trends-trendline";
        d.iconCollectionName = "ChartToolbarIcons";
        d.channel = "trends";
        d.iconWidth = 24;
        d.iconHeight = 25;
        var e = new ToolActionRadioInfo();
        e.name = "Logarithmic";
        e.title = "Logarithmic";
        e.iconName = "analyze-trends-log";
        e.iconCollectionName = "ChartToolbarIcons";
        e.channel = "trends";
        e.iconWidth = 24;
        e.iconHeight = 25;
        var f = new ToolActionRadioInfo();
        f.name = "NoTrends";
        f.title = "None";
        f.channel = "trends";
        f.iconName = "ig-NoIcon";
        return [a, b, c, d, e, f];
    };
    DataChartToolbarProvider.prototype.b = function () {
        var a = new ToolActionGroupHeaderInfo();
        a.name = "TimePeriodHighlightHeader";
        a.title = "TIME HIGHLIGHT";
        var b = new ToolActionSeparatorInfo();
        b.isGroupHeaderSeparator = true;
        var c = new ToolActionRadioInfo();
        c.name = "Quarters";
        c.title = "Quarters";
        c.channel = "time";
        var d = new ToolActionRadioInfo();
        d.name = "Seasons";
        d.title = "Seasons";
        d.channel = "time";
        var e = new ToolActionRadioInfo();
        e.name = "Weekends";
        e.title = "Weekends";
        e.channel = "time";
        var f = new ToolActionRadioInfo();
        f.name = "WorkDays";
        f.title = "Work days";
        f.channel = "time";
        return [a, b, c, d, e, f];
    };
    DataChartToolbarProvider.prototype.d = function (a) {
        var b = new ToolActionGroupHeaderInfo();
        b.name = "ValueLabelsHeader";
        b.title = "Value Labels";
        var c = new ToolActionSeparatorInfo();
        c.isGroupHeaderSeparator = true;
        var d = new ToolActionCheckboxInfo();
        d.name = "ShowValueLabels";
        d.title = "Show Value Labels";
        d.iconName = "analyze-valuelabels";
        d.iconCollectionName = "ChartToolbarIcons";
        d.iconWidth = 24;
        d.iconHeight = 24;
        var e = new ToolActionCheckboxInfo();
        e.name = "ShowLastValueLabel";
        e.title = "Show Last Value Label";
        e.iconName = "analyze-valuelabels-showlast";
        e.iconCollectionName = "ChartToolbarIcons";
        return [b, c, d, e];
    };
    DataChartToolbarProvider.prototype.m = function (a) {
        var e_2, _a;
        try {
            for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                if (this.h.isCalloutLayer(b) && this.h.getIsAutoCalloutBehaviorEnabled(b)) {
                    return b;
                }
            }
        }
        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;
            }
        }
        return null;
    };
    DataChartToolbarProvider.prototype.o = function (a) {
        var e_3, _a;
        try {
            for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                if (this.h.isFinalValueLayer(b)) {
                    return b;
                }
            }
        }
        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;
            }
        }
        return null;
    };
    DataChartToolbarProvider.prototype.p = function (a, b) {
        var e_4, _a;
        try {
            for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var c = _c.value;
                if (this.h.isValueLayer(c) && this.h.getValueMode(c) == b) {
                    return c;
                }
            }
        }
        catch (e_4_1) {
            e_4 = { error: e_4_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_4)
                    throw e_4.error;
            }
        }
        return null;
    };
    DataChartToolbarProvider.prototype.n = function (a) {
        var e_5, _a;
        try {
            for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                if (this.h.isCrosshairLayer(b)) {
                    return b;
                }
            }
        }
        catch (e_5_1) {
            e_5 = { error: e_5_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_5)
                    throw e_5.error;
            }
        }
        return null;
    };
    DataChartToolbarProvider.prototype.s = function (a) {
        var b = typeCast(XamDataChart.$, a);
        if (b != null) {
            for (var c = 0; c < b.axes.count; c++) {
                var d = b.axes._inner[c];
                if (d.na != null && !BrushUtilCore.a(d.na) && d.f1 != 0) {
                    return true;
                }
            }
        }
        return false;
    };
    DataChartToolbarProvider.prototype.onToolCommandExecuting = function (a, b) {
        switch (b.commandId) {
            case "ZoomReset":
                this.br(a, b);
                break;
            case "ZoomIn":
                this.bp(a, b);
                break;
            case "ZoomOut":
                this.bq(a, b);
                break;
            case "ShowCrosshairs":
                this.bd(a, b);
                break;
            case "ShowGridlines":
                this.bf(a, b);
                break;
            case "MaxValue":
                this.bj(a, b);
                break;
            case "MinValue":
                this.bk(a, b);
                break;
            case "Average":
                this.bb(a, b);
                break;
            case "Exponential":
                this.be(a, b);
                break;
            case "Linear":
                this.bh(a, b);
                break;
            case "Logarithmic":
                this.bi(a, b);
                break;
            case "NoTrends":
                this.bl(a, b);
                break;
            case "SeriesAvg":
                this.bm(a, b);
                break;
            case "ShowValueLabels":
                this.bo(a, b);
                break;
            case "ShowLastValueLabel":
                this.bn(a, b);
                break;
            case "CopyAsImage":
                this.bc(a, b);
                return 2;
        }
        return 0;
    };
    DataChartToolbarProvider.prototype.onTargetPropertyChanged = function (a, b, c, d) {
        var e_6, _a;
        switch (b) {
            case SeriesViewer.$$p[56]:
                if (Rect.l_op_Inequality(a.x5, null) && !a.x5.isEmpty && a.g4 != null) {
                    try {
                        for (var _b = __values(fromEnum(a.g4)), _c = _b.next(); !_c.done; _c = _b.next()) {
                            var e = _c.value;
                            e.setContextValue("ZoomResetIsDisabled", 5, Rect.l_op_Equality(a.x5, null) || a.x5.isEmpty || (a.x5.width >= 1 && a.x5.height >= 1));
                        }
                    }
                    catch (e_6_1) {
                        e_6 = { error: e_6_1 };
                    }
                    finally {
                        try {
                            if (_c && !_c.done && (_a = _b.return))
                                _a.call(_b);
                        }
                        finally {
                            if (e_6)
                                throw e_6.error;
                        }
                    }
                }
                break;
        }
    };
    DataChartToolbarProvider.prototype.w = function (a, b) {
        if (a.commandId == b) {
            var e = a.argumentsList;
            for (var d = 0; d < e.length; d++) {
                var c = e[d];
                if (c.argumentName == "IsChecked") {
                    return c.value;
                }
            }
        }
        return false;
    };
    DataChartToolbarProvider.prototype.bd = function (a, b) {
        var _this = this;
        var c = this.n(a);
        if (this.x(a, c)) {
            return;
        }
        this.bs(a, b, "ShowCrosshairs", 0, function () {
            var d = _this.h.createCrosshairLayer();
            _this.h.setCrosshairOnAxesEnabled(d, true);
            var e = new AutomaticSeriesRequest();
            e.a = 0;
            e.e = true;
            e.d = d;
            return e;
        });
    };
    DataChartToolbarProvider.prototype.f = function (a, b) {
        var c = new AxisStrokeSettings();
        c.b = a.ni == null || BrushUtilCore.a(a.ni) ? b : a.ni;
        c.a = isNaN_(a.f1) || a.f1 == 0 ? DeviceUtils.g(1) : a.f1;
        this.r.item(a, c);
        return c;
    };
    DataChartToolbarProvider.prototype.bf = function (a, b) {
        var c = this.w(b, "ShowGridlines");
        if (!c) {
            var d = typeCast(XamDataChart.$, a);
            if (d != null) {
                for (var e = 0; e < d.axes.count; e++) {
                    var f = d.axes._inner[e];
                    if (!this.r.d(f)) {
                        this.f(f, d.acc);
                    }
                    f.f1 = 0;
                }
            }
        }
        else {
            var g = typeCast(XamDataChart.$, a);
            if (g != null) {
                for (var h = 0; h < g.axes.count; h++) {
                    var i = g.axes._inner[h];
                    var j = true;
                    if (this.r.d(i)) {
                        if (this.r.item(i).b != i.ni || i.f1 != 0) {
                            j = true;
                        }
                        else {
                            i.ni = this.r.item(i).b;
                            i.f1 = this.r.item(i).a;
                            j = false;
                        }
                    }
                    if (j) {
                        var k = this.f(i, g.acc);
                        i.ni = k.b;
                        i.f1 = k.a;
                    }
                }
            }
        }
    };
    DataChartToolbarProvider.prototype.a9 = function (a, b, c, d) {
        var e_7, _a, e_8, _b;
        var e = a.ao(a);
        e.l(c);
        var f = new List$1(Series.$, 0);
        try {
            for (var _c = __values(fromEnum(a.series)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var g = _d.value;
                if (g.e0 || g.fb || g.fu || g.fq || g.fx) {
                    f.add(g);
                }
            }
        }
        catch (e_7_1) {
            e_7 = { error: e_7_1 };
        }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return))
                    _a.call(_c);
            }
            finally {
                if (e_7)
                    throw e_7.error;
            }
        }
        var h = 0;
        try {
            for (var _e = __values(fromEnum(f)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var i = _f.value;
                var j = this.h.createTrendLineLayer();
                this.h.setTrendLineTarget(j, i);
                this.h.setTrendLineType(j, b);
                this.h.setUseLegend(j, true);
                this.h.setLegendItemBadgeShape(j, 2);
                if (i.title != null && typeof i.title === 'string') {
                    var k = i.title;
                    this.h.setTitle(j, k + " " + d);
                }
                var l = new AutomaticSeriesRequest();
                l.a = c;
                l.c = i;
                l.d = j;
                e.b.add(l);
            }
        }
        catch (e_8_1) {
            e_8 = { error: e_8_1 };
        }
        finally {
            try {
                if (_f && !_f.done && (_b = _e.return))
                    _b.call(_e);
            }
            finally {
                if (e_8)
                    throw e_8.error;
            }
        }
    };
    DataChartToolbarProvider.prototype.be = function (a, b) {
        var c = this.w(b, "Exponential");
        if (c) {
            var d = a.ao(a);
            d.l(9);
            d.l(8);
            this.a9(a, 7, 7, "Exponential Fit");
        }
    };
    DataChartToolbarProvider.prototype.bh = function (a, b) {
        var c = this.w(b, "Linear");
        if (c) {
            var d = a.ao(a);
            d.l(9);
            d.l(7);
            this.a9(a, 1, 8, "Linear Fit");
        }
    };
    DataChartToolbarProvider.prototype.bi = function (a, b) {
        var c = this.w(b, "Logarithmic");
        if (c) {
            var d = a.ao(a);
            d.l(8);
            d.l(7);
            this.a9(a, 6, 9, "Logarithmic Fit");
        }
    };
    DataChartToolbarProvider.prototype.bl = function (a, b) {
        var c = a.ao(a);
        c.l(7);
        c.l(8);
        c.l(9);
    };
    DataChartToolbarProvider.prototype.bs = function (a, b, c, d, e) {
        var f = this.w(b, c);
        var g = a.ao(a);
        if (f && !g.e(d)) {
            if (this.t && e != null) {
                g.b.add(e());
            }
        }
        if (!f && g.e(d)) {
            g.l(d);
        }
    };
    DataChartToolbarProvider.prototype.bj = function (a, b) {
        var _this = this;
        var c = this.p(a, 5);
        if (c != null && this.h.getValueMode(c) == 5 && this.x(a, c)) {
            return;
        }
        this.bs(a, b, "MaxValue", 1, function () {
            var d = _this.h.createValueLayer();
            _this.h.setValueMode(d, 5);
            _this.h.setValueAxisAnnotationEnabled(d, true);
            _this.h.setUseLegend(d, true);
            _this.h.setTitle(d, "Maximum");
            _this.h.setLegendItemBadgeShape(d, 2);
            var e = new AutomaticSeriesRequest();
            e.a = 1;
            e.e = true;
            e.d = d;
            return e;
        });
    };
    DataChartToolbarProvider.prototype.bk = function (a, b) {
        var _this = this;
        var c = this.p(a, 4);
        if (c != null && this.x(a, c)) {
            return;
        }
        this.bs(a, b, "MinValue", 2, function () {
            var d = _this.h.createValueLayer();
            _this.h.setValueMode(d, 4);
            _this.h.setValueAxisAnnotationEnabled(d, true);
            _this.h.setUseLegend(d, true);
            _this.h.setTitle(d, "Minimum");
            _this.h.setLegendItemBadgeShape(d, 2);
            var e = new AutomaticSeriesRequest();
            e.a = 2;
            e.e = true;
            e.d = d;
            return e;
        });
    };
    DataChartToolbarProvider.prototype.bb = function (a, b) {
        var _this = this;
        var c = this.p(a, 6);
        if (c != null && this.x(a, c)) {
            return;
        }
        this.bs(a, b, "Average", 3, function () {
            var d = _this.h.createValueLayer();
            _this.h.setValueMode(d, 6);
            _this.h.setValueAxisAnnotationEnabled(d, true);
            _this.h.setUseLegend(d, true);
            _this.h.setTitle(d, "Average");
            _this.h.setLegendItemBadgeShape(d, 2);
            var e = new AutomaticSeriesRequest();
            e.a = 3;
            e.e = true;
            e.d = d;
            return e;
        });
    };
    DataChartToolbarProvider.prototype.bm = function (a, b) {
        var c = a.ao(a);
        var d = this.p(a, 3);
        if (d != null) {
            c.l(4);
            return;
        }
        if (!this.t) {
            return;
        }
        var e = a.series.count;
        for (var f = 0; f < e; f++) {
            var g = a.series._inner[f];
            if (g.eu) {
                continue;
            }
            var h = this.h.createValueLayer();
            this.h.setValueMode(h, 3);
            this.h.setValueAxisAnnotationEnabled(h, true);
            this.h.setUseLegend(h, a.gj);
            if (g.title != null && typeof g.title === 'string') {
                var i = g.title;
                this.h.setTitle(h, i + " Avg");
            }
            this.h.setLegendItemBadgeShape(h, 2);
            this.h.setTargetSeries(h, g);
            this.h.setBrush(h, g.vj);
            var j = new AutomaticSeriesRequest();
            j.a = 4;
            j.e = true;
            j.d = h;
            c.b.add(j);
        }
    };
    DataChartToolbarProvider.prototype.x = function (a, b) {
        var e_9, _a;
        if (b != null) {
            var c = false;
            var d = a.ao(a);
            try {
                for (var _b = __values(fromEnum(d.b)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var e = _c.value;
                    if (e.d == b) {
                        c = true;
                        break;
                    }
                }
            }
            catch (e_9_1) {
                e_9 = { error: e_9_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_9)
                        throw e_9.error;
                }
            }
            if (!c) {
                if (b._visibility == 0) {
                    var cl_ = b;
                    var v_ = 1;
                    cl_.visibility = v_;
                    return true;
                }
                else if (b._visibility == 1) {
                    var cl_ = b;
                    var v_ = 0;
                    cl_.visibility = v_;
                    return true;
                }
            }
        }
        return false;
    };
    DataChartToolbarProvider.prototype.bo = function (a, b) {
        var _this = this;
        var c = this.m(a);
        if (this.x(a, c)) {
            return;
        }
        this.bs(a, b, "ShowValueLabels", 5, function () {
            var e_10, _a;
            try {
                for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var d = _c.value;
                    if (d.e0) {
                        if (_this.v && _this.l.matchesType(d)) {
                            var e = _this.l.getMarkerType(d);
                            if (e == 1) {
                                _this.l.setMarkerType(d, 13);
                            }
                        }
                    }
                }
            }
            catch (e_10_1) {
                e_10 = { error: e_10_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_10)
                        throw e_10.error;
                }
            }
            var f = _this.h.createCalloutLayer();
            _this.h.setIsAutoCalloutBehaviorEnabled(f, true);
            var g = new AutomaticSeriesRequest();
            g.a = 5;
            g.e = true;
            g.d = f;
            return g;
        });
    };
    DataChartToolbarProvider.prototype.bn = function (a, b) {
        var _this = this;
        var c = this.o(a);
        if (this.x(a, c)) {
            return;
        }
        this.bs(a, b, "ShowLastValueLabel", 6, function () {
            var e_11, _a;
            try {
                for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var d = _c.value;
                    var e = d.ai();
                    if (e != null) {
                        for (var g = 0; g < e.length; g++) {
                            var f = e[g];
                            if (f.dh) {
                                f.dv = true;
                            }
                        }
                    }
                }
            }
            catch (e_11_1) {
                e_11 = { error: e_11_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_11)
                        throw e_11.error;
                }
            }
            var h = _this.h.createFinalValueLayer();
            var i = new AutomaticSeriesRequest();
            i.a = 6;
            i.e = true;
            i.d = h;
            return i;
        });
    };
    DataChartToolbarProvider.prototype.bc = function (a, b) {
        this.q = b;
        var c = new CaptureImageSettings();
        c.b = true;
        c.a = 0;
        a.imageCaptured = delegateCombine(a.imageCaptured, runOn(this, this.bg));
        a.n8(c);
        a.al.q();
    };
    DataChartToolbarProvider.prototype.bg = function (a, b) {
        this.q.argumentsList = [((function () {
                var $ret = new ToolCommandArgument();
                $ret.argumentName = "Image";
                $ret.value = b.base64Data;
                return $ret;
            })())];
        var c = a;
        c.imageCaptured = delegateRemove(c.imageCaptured, runOn(this, this.bg));
        if (c.commandCompleted != null) {
            c.commandCompleted(this.q);
        }
    };
    DataChartToolbarProvider.prototype.bp = function (a, b) {
        a.tb(0.05);
    };
    DataChartToolbarProvider.prototype.bq = function (a, b) {
        a.tc(0.05);
    };
    DataChartToolbarProvider.prototype.br = function (a, b) {
        a.sj();
    };
    DataChartToolbarProvider.$t = markType(DataChartToolbarProvider, 'DataChartToolbarProvider', Base.$, [IDataChartToolbarProvider_$type]);
    return DataChartToolbarProvider;
}(Base));
export { DataChartToolbarProvider };
