/*
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 { Base, runOn, delegateCombine, delegateRemove, markType } from "igniteui-react-core";
import { IDomainChartToolbarProvider_$type } from "./IDomainChartToolbarProvider";
import { ToolCommandStateChanged } from "igniteui-react-core";
import { ValueModeCollection } from "./ValueModeCollection";
import { BrushCollection } from "igniteui-react-core";
import { BrushUtil } from "igniteui-react-core";
import { CaptureImageSettings } from "igniteui-react-core";
/**
 * @hidden
 */
export let DomainChartToolbarProvider = /*@__PURE__*/ (() => {
    class DomainChartToolbarProvider extends Base {
        constructor() {
            super(...arguments);
            this.a = null;
            this.b = false;
            this._container = null;
            this._commandChanged = null;
        }
        get container() {
            return this._container;
        }
        set container(a) {
            this._container = a;
        }
        get commandChanged() {
            return this._commandChanged;
        }
        set commandChanged(a) {
            this._commandChanged = a;
        }
        getDesiredToolbarActions(a, b) {
            for (let c = 0; c < b.length; c++) {
                this.d(a, b[c]);
            }
            return b;
        }
        d(a, b) {
            if (b.actions != null && b.actions.length > 0) {
                for (let c = 0; c < b.actions.length; c++) {
                    this.d(a, b.actions[c]);
                }
            }
            switch (b.name) {
                case "ShowCrosshairs":
                    {
                        let d = b;
                        d.isChecked = a.a9 != 1;
                    }
                    break;
                case "ShowGridlines":
                    {
                        let e = b;
                        e.isChecked = a.fu;
                    }
                    break;
                case "ShowValueLabels":
                    {
                        let f = b;
                        f.isChecked = a.fu;
                    }
                    break;
                case "ShowLastValueLabel":
                    {
                        let g = b;
                        g.isChecked = a.f4;
                    }
                    break;
                case "MinValue":
                    {
                        if (a.dx != null) {
                            let h = b;
                            for (let i = 0; i < a.dx.count; i++) {
                                if (a.dx._inner[i] == 4) {
                                    h.isChecked = true;
                                    break;
                                }
                            }
                        }
                    }
                    break;
                case "MaxValue":
                    {
                        if (a.dx != null) {
                            let j = b;
                            for (let k = 0; k < a.dx.count; k++) {
                                if (a.dx._inner[k] == 5) {
                                    j.isChecked = true;
                                    break;
                                }
                            }
                        }
                    }
                    break;
                case "Average":
                    {
                        if (a.dx != null) {
                            let l = b;
                            for (let m = 0; m < a.dx.count; m++) {
                                if (a.dx._inner[m] == 6) {
                                    l.isChecked = true;
                                    break;
                                }
                            }
                        }
                    }
                    break;
                case "SeriesAvg":
                    {
                        if (a.dx != null) {
                            let n = b;
                            for (let o = 0; o < a.dx.count; o++) {
                                if (a.dx._inner[o] == 3) {
                                    n.isChecked = true;
                                    break;
                                }
                            }
                        }
                    }
                    break;
            }
            this.e(a, b);
        }
        e(a, b) {
        }
        onToolCommandExecuting(a, b) {
            this.b = true;
            let c = 0;
            switch (b.commandId) {
                case "ZoomReset":
                    this.x(a, b);
                    break;
                case "ZoomIn":
                    this.v(a, b);
                    break;
                case "ZoomOut":
                    this.w(a, b);
                    break;
                case "ShowCrosshairs":
                    this.i(a, b);
                    break;
                case "ShowGridlines":
                    this.k(a, b);
                    break;
                case "MaxValue":
                    this.o(a, b);
                    break;
                case "MinValue":
                    this.p(a, b);
                    break;
                case "Average":
                    this.g(a, b);
                    break;
                case "Exponential":
                    this.j(a, b);
                    break;
                case "Linear":
                    this.m(a, b);
                    break;
                case "Logarithmic":
                    this.n(a, b);
                    break;
                case "NoTrends":
                    this.q(a, b);
                    break;
                case "SeriesAvg":
                    this.r(a, b);
                    break;
                case "ShowValueLabels":
                    this.t(a, b);
                    break;
                case "ShowLastValueLabel":
                    this.s(a, b);
                    break;
                case "CopyAsImage":
                    this.h(a, b);
                    c = 2;
                    break;
            }
            this.b = false;
            return c;
        }
        onTargetPropertyChanged(a, b, c, d) {
            if (this.b) {
                return;
            }
            switch (b) {
                case "CrosshairsDisplayMode":
                    if (a.a9 == 1) {
                        this.f("ShowCrosshairs", 2, false);
                    }
                    else {
                        this.f("ShowCrosshairs", 2, true);
                    }
                    break;
                case "AutoCalloutsVisible":
                    this.f("ShowValueLabels", 2, a.fu);
                    break;
                case "FinalValueAnnotationsVisible":
                    this.f("ShowLastValueLabel", 2, a.f4);
                    break;
            }
            this.u(a, b, c, d);
        }
        u(a, b, c, d) {
        }
        f(a, b, c) {
            if (this.commandChanged != null) {
                this.commandChanged(((() => {
                    let $ret = new ToolCommandStateChanged();
                    $ret.c = a;
                    $ret.a = b;
                    $ret.b = c;
                    return $ret;
                })()));
            }
        }
        c(a, b) {
            let e = a.argumentsList;
            for (let d = 0; d < e.length; d++) {
                let c = e[d];
                if (c.argumentName == b) {
                    return c.value;
                }
            }
            return false;
        }
        i(a, b) {
            if (this.c(b, "ShowCrosshairs")) {
                a.a9 = 0;
                a.fx = true;
            }
            else {
                a.a9 = 1;
            }
        }
        k(a, b) {
        }
        j(a, b) {
            if (this.c(b, "Exponential")) {
                a.dt = 7;
            }
            else {
                a.dt = 0;
            }
        }
        m(a, b) {
            if (this.c(b, "Linear")) {
                a.dt = 1;
            }
            else {
                a.dt = 0;
            }
        }
        n(a, b) {
            if (this.c(b, "Logarithmic")) {
                a.dt = 6;
            }
            else {
                a.dt = 0;
            }
        }
        q(a, b) {
            if (this.c(b, "NoTrends")) {
                a.dt = 0;
            }
        }
        o(a, b) {
            if (this.c(b, "MaxValue")) {
                if (a.dx == null) {
                    a.dx = new ValueModeCollection();
                }
                if (a.ai == null) {
                    a.ai = new BrushCollection();
                }
                a.dx.add(5);
                a.ai.add(BrushUtil.h(255, 99, 208, 0));
            }
            else {
                for (let c = 0; c < a.dx.count; c++) {
                    if (a.dx._inner[c] == 5) {
                        a.dx.removeAt(c);
                        a.ai.removeAt(c);
                        c--;
                    }
                }
            }
        }
        p(a, b) {
            if (this.c(b, "MinValue")) {
                if (a.dx == null) {
                    a.dx = new ValueModeCollection();
                }
                if (a.ai == null) {
                    a.ai = new BrushCollection();
                }
                a.dx.add(4);
                a.ai.add(BrushUtil.h(255, 246, 93, 80));
            }
            else {
                for (let c = 0; c < a.dx.count; c++) {
                    if (a.dx._inner[c] == 4) {
                        a.dx.removeAt(c);
                        a.ai.removeAt(c);
                        c--;
                    }
                }
            }
        }
        g(a, b) {
            if (this.c(b, "Average")) {
                if (a.dx == null) {
                    a.dx = new ValueModeCollection();
                }
                if (a.ai == null) {
                    a.ai = new BrushCollection();
                }
                a.dx.add(6);
                a.ai.add(BrushUtil.h(255, 248, 173, 118));
            }
            else {
                for (let c = 0; c < a.dx.count; c++) {
                    if (a.dx._inner[c] == 6) {
                        a.dx.removeAt(c);
                        a.ai.removeAt(c);
                        c--;
                    }
                }
            }
        }
        r(a, b) {
            if (this.c(b, "SeriesAvg")) {
                if (a.dx == null) {
                    a.dx = new ValueModeCollection();
                }
                a.dx.add(3);
            }
            else {
                for (let c = 0; c < a.dx.count; c++) {
                    if (a.dx._inner[c] == 3) {
                        a.dx.removeAt(c);
                        c--;
                    }
                }
            }
        }
        t(a, b) {
            if (this.c(b, "ShowValueLabels")) {
                a.fu = true;
            }
            else {
                a.fu = false;
            }
        }
        s(a, b) {
            if (this.c(b, "ShowLastValueLabel")) {
                a.f4 = true;
                a.gm = true;
            }
            else {
                a.f4 = false;
            }
        }
        h(a, b) {
            this.a = b;
            let c = new CaptureImageSettings();
            c.b = true;
            c.a = 0;
            let d = a.dataChart;
            d.imageCaptured = delegateCombine(d.imageCaptured, runOn(this, this.l));
            a.dataChart.lv(c);
            a.dataChart.al.q();
        }
        l(a, b) {
            this.a.argumentsList[0].value = b.base64Data;
            let c = a;
            c.imageCaptured = delegateRemove(c.imageCaptured, runOn(this, this.l));
            if (c.commandCompleted != null) {
                c.commandCompleted(this.a);
            }
        }
        v(a, b) {
            a.t9(0.05);
        }
        w(a, b) {
            a.ua(0.05);
        }
        x(a, b) {
            a.t5();
        }
    }
    DomainChartToolbarProvider.$t = /*@__PURE__*/ markType(DomainChartToolbarProvider, 'DomainChartToolbarProvider', Base.$, [IDomainChartToolbarProvider_$type]);
    return DomainChartToolbarProvider;
})();
