/*
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 { Series } from "./Series";
import { IHasCategoryModePreference_$type } from "./IHasCategoryModePreference";
import { Axis } from "./Axis";
import { DependencyProperty } from "igniteui-angular-core";
import { CategoryAxisBase } from "./CategoryAxisBase";
import { Point_$type, typeCast, Delegate_$type, markType, markDep } from "igniteui-angular-core";
import { Brush } from "igniteui-angular-core";
import { Thickness } from "igniteui-angular-core";
import { AxisAnnotationFrame } from "./AxisAnnotationFrame";
import { List$1 } from "igniteui-angular-core";
import { Dictionary$2 } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
import { AxisAnnotation } from "./AxisAnnotation";
import { SeriesView } from "./SeriesView";
import { NotImplementedException } from "igniteui-angular-core";
import { AxisRange } from "./AxisRange";
import { NumericAxisBase } from "./NumericAxisBase";
import { ScalerParams } from "./ScalerParams";
import { CategoryXAxis } from "./CategoryXAxis";
import { AxisAnnotationFrameManager } from "./AxisAnnotationFrameManager";
import { PropertyMetadata } from "igniteui-angular-core";
import { DeviceUtils } from "igniteui-angular-core";
import { isNaN_, isInfinity } from "igniteui-angular-core";
import { stringFormat } from "igniteui-angular-core";
import { Path } from "igniteui-angular-core";
/**
 * @hidden
 */
var ValueOverlay = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(ValueOverlay, _super);
    function ValueOverlay() {
        var _this = _super.call(this) || this;
        _this.qk = 0;
        _this.ql = 0;
        _this.qh = 0;
        _this.p4 = null;
        _this.qa = null;
        _this.p9 = null;
        _this.ab = ValueOverlay.$;
        return _this;
    }
    ValueOverlay.prototype.gj = function (a, b, c) {
        return this.qm;
    };
    ValueOverlay.prototype.qi = function (a, b) {
        var c = Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
        var d = Math.acos((a.x - b.x) / c);
        if ((a.y - b.y) < 0) {
            d = (2 * Math.PI) - d;
        }
        return d;
    };
    ValueOverlay.prototype.pl = function (a, b, c) {
        if (this.p3 == null) {
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        var d = this.qj();
        var e = NaN;
        var f = NaN;
        var g = NaN;
        var h = { $type: Point_$type, x: 0.5, y: 0.5 };
        var i = NaN;
        switch (this.p3.a1) {
            case 2:
                i = Math.sqrt(Math.pow(a.x - h.x, 2) + Math.pow(a.y - h.y, 2));
                g = d;
                e = h.x + Math.cos(g) * i;
                f = h.y + Math.sin(g) * i;
                f = this.b0.bu.top + this.b0.bu.height * (f - this.b0.bv.top) / this.b0.bv.height;
                e = this.b0.bu.left + this.b0.bu.width * (e - this.b0.bv.left) / this.b0.bv.width;
                break;
            case 0:
                e = d;
                f = a.y;
                f = this.b0.bu.top + this.b0.bu.height * (f - this.b0.bv.top) / this.b0.bv.height;
                break;
            case 1:
                f = d;
                e = a.x;
                e = this.b0.bu.left + this.b0.bu.width * (e - this.b0.bv.left) / this.b0.bv.width;
                break;
            case 3:
                g = this.qi(a, h);
                i = d;
                e = h.x + Math.cos(g) * i;
                f = h.y + Math.sin(g) * i;
                f = this.b0.bu.top + this.b0.bu.height * (f - this.b0.bv.top) / this.b0.bv.height;
                e = this.b0.bu.left + this.b0.bu.width * (e - this.b0.bv.left) / this.b0.bv.width;
                break;
        }
        return { $type: Point_$type, x: e, y: f };
    };
    ValueOverlay.prototype.hd = function (a) {
        throw new NotImplementedException(0);
    };
    ValueOverlay.prototype.ht = function (a) {
        return this;
    };
    ValueOverlay.prototype.en = function (a) {
        return false;
    };
    ValueOverlay.prototype.ap = function (a) {
        var b = typeCast(NumericAxisBase.$, a);
        var c = this.qm;
        if (isNaN_(c) || isInfinity(c)) {
            return null;
        }
        return new AxisRange(c, c);
    };
    ValueOverlay.prototype.mi = function (a) {
        this.kx(true, this.b0);
        if (!this.p8()) {
            if (this.p4 != null) {
                this.q5(NaN, this.cv());
            }
            return;
        }
        if (this.eo(a)) {
            if (this.cv()) {
                if (this.ce.g) {
                    this.ce.t();
                }
                var b = this.qk;
                this.qk = this.ql;
                this.ql = b;
            }
            else {
                this.qk = this.qh;
            }
            this.qh = this.qj();
            this.mq();
        }
        else {
            this.qh = this.qj();
            this.q4(this.qh, this.p6);
        }
    };
    ValueOverlay.prototype.qj = function () {
        var a, b;
        var c = this.getViewInfo(b, a);
        b = c.p0;
        a = c.p1;
        var d = this.getEffectiveViewport1(this.b0);
        var e = new ScalerParams(0, a, b, this.p3.cg, d);
        return this.p3.ei(this.qm, e);
    };
    ValueOverlay.prototype.q4 = function (a, b) {
        if (this.p3 == null) {
            return;
        }
        var c = typeCast(CategoryAxisBase.$, this.p3);
        if (c != null && !c.cd) {
            if (this.qm > c.lf - 1) {
                return;
            }
            if (c.categoryMode != 0) {
                var d = this.getEffectiveViewport1(b);
                var e = 0.5 * c.getCategorySize(b.bv, b.bu, d);
                var f = false;
                if (c.co && !c.cg) {
                    f = true;
                }
                if (typeCast(CategoryXAxis.$, c) !== null && c.cg) {
                    f = true;
                }
                if (f) {
                    e = -e;
                }
                a += e;
            }
        }
        var g = typeCast(NumericAxisBase.$, this.p3);
        if (g != null) {
            if (this.qm < g.lv || this.qm > g.lu) {
                return;
            }
            if (g.lh && this.qm < 0) {
                return;
            }
        }
        var h;
        switch (this.p3.a1) {
            case 2:
            case 3:
                h = this.p3.j4(a, b.bv, b.bu, this.getEffectiveViewport1(b), this.pq(b));
                break;
            default:
                h = this.p3.j4(a, b.bv, b.bu);
                break;
        }
        if (h != null) {
            b.by(h);
        }
        if (!b.q) {
            this.q5(a, this.cv());
        }
    };
    ValueOverlay.prototype.e9 = function (a, b, c) {
        var d = true;
        d = _super.prototype.e9.call(this, a, b, c);
        if (!c.o() || b.isEmpty || a.isEmpty || this.p3 == null || this.p3.bh == null) {
            d = false;
        }
        return d;
    };
    ValueOverlay.prototype.m5 = function (a, b) {
        this.mh(false);
    };
    ValueOverlay.prototype.m4 = function (a, b) {
        this.mh(false);
    };
    ValueOverlay.prototype.k0 = function (a, b, c, d) {
        throw new NotImplementedException(0);
    };
    ValueOverlay.prototype.l3 = function (a, b, c, d) {
        _super.prototype.l3.call(this, a, b, c, d);
        switch (b) {
            case ValueOverlay.$$p[11]:
                if (c != null) {
                    c.bz(this);
                }
                if (d != null) {
                    d.cs(this);
                }
                this.mh(false);
                this.lo();
                break;
            case "TransitionProgress":
                this.ql = this.qk + this.g0 * (this.qh - this.qk);
                if (this.cx(this.b0)) {
                    return;
                }
                if (this.g0 == 1) {
                    this.q4(this.qh, this.p6);
                }
                else {
                    this.q4(this.ql, this.p6);
                }
                if (this.cd != null) {
                    this.cd.nn(this);
                }
                break;
            case ValueOverlay.$$p[13]:
                var e = typeCast(NumericAxisBase.$, this.p3);
                if (e != null) {
                    e.c0();
                }
                this.mh(true);
                this.lp();
                break;
            case ValueOverlay.$$p[12]:
            case ValueOverlay.$$p[10]:
            case ValueOverlay.$$p[1]:
            case ValueOverlay.$$p[0]:
            case ValueOverlay.$$p[3]:
            case ValueOverlay.$$p[4]:
            case ValueOverlay.$$p[9]:
            case ValueOverlay.$$p[5]:
            case ValueOverlay.$$p[6]:
            case ValueOverlay.$$p[7]:
            case ValueOverlay.$$p[8]:
                this.mh(true);
                break;
        }
    };
    ValueOverlay.prototype.le = function () {
        _super.prototype.le.call(this);
        if (this.p3 != null) {
            this.p3.h7(false);
        }
    };
    ValueOverlay.prototype.kx = function (a, b) {
        _super.prototype.kx.call(this, a, b);
        var c = b;
        c.bx();
    };
    ValueOverlay.prototype.p8 = function () {
        if (this.p3 == null || this.p3.bh == null || isNaN_(this.qm) || this._visibility != 0) {
            return false;
        }
        var a = typeCast(CategoryAxisBase.$, this.p3);
        if (a != null && a.lf == 0) {
            return false;
        }
        return true;
    };
    ValueOverlay.prototype.preferredCategoryMode = function (a) {
        return 0;
    };
    Object.defineProperty(ValueOverlay.prototype, "categoryAxis", {
        get: function () {
            return typeCast(CategoryAxisBase.$, this.p3);
        },
        enumerable: false,
        configurable: true
    });
    ValueOverlay.prototype.bx = function () {
        return new ValueOverlayView(this);
    };
    ValueOverlay.prototype.ly = function (a) {
        _super.prototype.ly.call(this, a);
        this.p6 = typeCast(ValueOverlayView.$, a);
    };
    ValueOverlay.prototype.mj = function (a, b) {
        _super.prototype.mj.call(this, a, b);
        if (!this.ez) {
            this.b0.a2(b);
            return;
        }
        this.b0.a2(b);
        if (this.cx(this.bz) || !this.p8()) {
            return;
        }
        var c = this.getEffectiveViewport1(this.b0);
        var d = this.p3.ei(this.qm, new ScalerParams(0, this.bz.bv, a, this.p3.cg, c));
        this.q4(d, typeCast(ValueOverlayView.$, this.bz));
        this.ez = false;
    };
    ValueOverlay.prototype.getOffsetValue = function () {
        return 0;
    };
    ValueOverlay.prototype.getCategoryWidth = function () {
        return 0;
    };
    Object.defineProperty(ValueOverlay.prototype, "rn", {
        get: function () {
            return new Thickness(1, this.qd, this.qf, this.qe, this.qc);
        },
        enumerable: false,
        configurable: true
    });
    ValueOverlay.prototype.ag = function () {
        return [this.p3];
    };
    ValueOverlay.prototype.q5 = function (a, b) {
        if (isNaN_(a)) {
            if (this.p4 != null) {
                AxisAnnotationFrameManager.b(this.p4);
                AxisAnnotationFrameManager.d(this, this.p4, true, this.p9, this.qa, b, this.qn, this.qn, this.p5, this.p5);
            }
            return;
        }
        var c = false;
        if (this.p9 == null) {
            c = true;
            this.qa = new List$1(Axis.$, 0);
            this.p9 = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
        }
        this.p4 = new AxisAnnotationFrame();
        var d = this.oy;
        if (d == null) {
            d = this.o2;
        }
        var e = this.p3.co;
        AxisAnnotationFrameManager.c(this.p4, { $type: Point_$type, x: a, y: a }, this, this.cd, this.getEffectiveViewport(), d, this.rk, this.qb, this.rm, this.rl, this.rn, this.qg, this.rk, this.qb, this.rm, this.rl, this.rn, this.qg, !e && this.p7, e && this.p7);
        AxisAnnotationFrameManager.d(this, this.p4, c, this.p9, this.qa, b, this.qn, this.qn, this.p5, this.p5);
    };
    ValueOverlay.prototype.get_isValueOverlay = function () {
        return true;
    };
    ValueOverlay.prototype.q0 = function (a) {
        if (this.p3 != null) {
            return this.p3.gc(a);
        }
        return null;
    };
    Object.defineProperty(ValueOverlay.prototype, "q2", {
        get: function () {
            var a = this.q0(this.qm);
            return a != null ? a : stringFormat("{0:0.##}", this.qm);
        },
        enumerable: false,
        configurable: true
    });
    ValueOverlay.$t = markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]);
    ValueOverlay.$$p = markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:qb:q6', [1, DeviceUtils.g(3)], 'AxisAnnotationBackground:rk:q7', [Brush.$, null], 'AxisAnnotationFormatLabel:p5:q8', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:qn:q9', [1, -1], 'AxisAnnotationOutline:rl:ra', [Brush.$, null], 'AxisAnnotationPaddingBottom:qc:rb', [1, NaN], 'AxisAnnotationPaddingLeft:qd:rc', [1, NaN], 'AxisAnnotationPaddingRight:qe:rd', [1, NaN], 'AxisAnnotationPaddingTop:qf:re', [1, NaN], 'AxisAnnotationStrokeThickness:qg:rf', [1, NaN], 'AxisAnnotationTextColor:rm:rg', [Brush.$, null], 'Axis:p3:rh', [Axis.$, null], 'IsAxisAnnotationEnabled:p7:ri', [0, false], 'Value:qm:rj', [1, 0]]);
    return ValueOverlay;
}(Series));
export { ValueOverlay };
/**
 * @hidden
 */
var ValueOverlayView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(ValueOverlayView, _super);
    function ValueOverlayView(a) {
        var _this = _super.call(this, a) || this;
        _this.bz = null;
        _this.bz = new Path();
        return _this;
    }
    ValueOverlayView.prototype.bb = function () {
        _super.prototype.bb.call(this);
        this.bz._stroke = this.e.oy;
        this.bz.ac = this.e.fu;
        this.bz.ai = this.e.pb;
        this.bz.ad = this.e.pc;
    };
    ValueOverlayView.prototype.bc = function () {
        _super.prototype.bc.call(this);
        var a = this.bo();
        this.bz._stroke = a;
        this.bz.ac = this.e.fu + 3;
        this.bz._stroke = a;
        this.bz.ac = this.e.fu + 3;
    };
    ValueOverlayView.prototype.by = function (a) {
        this.bz.ak = a;
        this.aq();
    };
    ValueOverlayView.prototype.bx = function () {
        this.bz.ak = null;
        this.aq();
    };
    ValueOverlayView.prototype.a6 = function (a, b) {
        _super.prototype.a6.call(this, a, b);
        if (a.d) {
            a.s(this.bz);
        }
    };
    ValueOverlayView.prototype.al = function (a) {
        _super.prototype.al.call(this, a);
        this.e.a8.exportPathData(a, this.bz, "ValueOverlayPath", []);
    };
    ValueOverlayView.$t = markType(ValueOverlayView, 'ValueOverlayView', SeriesView.$);
    return ValueOverlayView;
}(SeriesView));
export { ValueOverlayView };
