/*
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.qt = 0;
        _this.qu = 0;
        _this.qq = 0;
        _this.qd = null;
        _this.qj = null;
        _this.qi = null;
        _this.ab = ValueOverlay.$;
        return _this;
    }
    ValueOverlay.prototype.gn = function (a, b, c) {
        return this.qv;
    };
    ValueOverlay.prototype.qr = 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.ps = function (a, b, c) {
        if (this.qc == null) {
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        var d = this.qs();
        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.qc.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.b1.bu.top + this.b1.bu.height * (f - this.b1.bv.top) / this.b1.bv.height;
                e = this.b1.bu.left + this.b1.bu.width * (e - this.b1.bv.left) / this.b1.bv.width;
                break;
            case 0:
                e = d;
                f = a.y;
                f = this.b1.bu.top + this.b1.bu.height * (f - this.b1.bv.top) / this.b1.bv.height;
                break;
            case 1:
                f = d;
                e = a.x;
                e = this.b1.bu.left + this.b1.bu.width * (e - this.b1.bv.left) / this.b1.bv.width;
                break;
            case 3:
                g = this.qr(a, h);
                i = d;
                e = h.x + Math.cos(g) * i;
                f = h.y + Math.sin(g) * i;
                f = this.b1.bu.top + this.b1.bu.height * (f - this.b1.bv.top) / this.b1.bv.height;
                e = this.b1.bu.left + this.b1.bu.width * (e - this.b1.bv.left) / this.b1.bv.width;
                break;
        }
        return { $type: Point_$type, x: e, y: f };
    };
    ValueOverlay.prototype.hi = function (a) {
        throw new NotImplementedException(0);
    };
    ValueOverlay.prototype.hy = function (a) {
        return this;
    };
    ValueOverlay.prototype.eq = function (a) {
        return false;
    };
    ValueOverlay.prototype.aq = function (a) {
        var b = typeCast(NumericAxisBase.$, a);
        var c = this.qv;
        if (isNaN_(c) || isInfinity(c)) {
            return null;
        }
        return new AxisRange(c, c);
    };
    ValueOverlay.prototype.mo = function (a) {
        this.k2(true, this.b1);
        if (!this.qh()) {
            if (this.qd != null) {
                this.re(NaN, this.cw());
            }
            return;
        }
        if (this.er(a)) {
            if (this.cw()) {
                if (this.cf.g) {
                    this.cf.t();
                }
                var b = this.qt;
                this.qt = this.qu;
                this.qu = b;
            }
            else {
                this.qt = this.qq;
            }
            this.qq = this.qs();
            this.mw();
        }
        else {
            this.qq = this.qs();
            this.rd(this.qq, this.qf);
        }
    };
    ValueOverlay.prototype.qs = function () {
        var a, b;
        var c = this.getViewInfo(b, a);
        b = c.p0;
        a = c.p1;
        var d = this.getEffectiveViewport1(this.b1);
        var e = new ScalerParams(0, a, b, this.qc.cg, d);
        return this.qc.ei(this.qv, e);
    };
    ValueOverlay.prototype.rd = function (a, b) {
        if (this.qc == null) {
            return;
        }
        var c = typeCast(CategoryAxisBase.$, this.qc);
        if (c != null && !c.cd) {
            if (this.qv > 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.qc);
        if (g != null) {
            if (this.qv < g.lw || this.qv > g.lv) {
                return;
            }
            if (g.li && this.qv < 0) {
                return;
            }
        }
        var h;
        switch (this.qc.a1) {
            case 2:
            case 3:
                h = this.qc.j4(a, b.bv, b.bu, this.getEffectiveViewport1(b), this.pz(b));
                break;
            default:
                h = this.qc.j4(a, b.bv, b.bu);
                break;
        }
        if (h != null) {
            b.by(h);
        }
        if (!b.q) {
            this.re(a, this.cw());
        }
    };
    ValueOverlay.prototype.fd = function (a, b, c) {
        var d = true;
        d = _super.prototype.fd.call(this, a, b, c);
        if (!c.o() || b.isEmpty || a.isEmpty || this.qc == null || this.qc.bh == null) {
            d = false;
        }
        return d;
    };
    ValueOverlay.prototype.nb = function (a, b) {
        this.mn(false);
    };
    ValueOverlay.prototype.na = function (a, b) {
        this.mn(false);
    };
    ValueOverlay.prototype.k5 = function (a, b, c, d) {
        throw new NotImplementedException(0);
    };
    ValueOverlay.prototype.l9 = function (a, b, c, d) {
        _super.prototype.l9.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.mn(false);
                this.lu();
                break;
            case "TransitionProgress":
                this.qu = this.qt + this.g5 * (this.qq - this.qt);
                if (this.cy(this.b1)) {
                    return;
                }
                if (this.g5 == 1) {
                    this.rd(this.qq, this.qf);
                }
                else {
                    this.rd(this.qu, this.qf);
                }
                if (this.ce != null) {
                    this.ce.ob(this);
                }
                break;
            case ValueOverlay.$$p[13]:
                var e = typeCast(NumericAxisBase.$, this.qc);
                if (e != null) {
                    e.c0();
                }
                this.mn(true);
                this.lv();
                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.mn(true);
                break;
        }
    };
    ValueOverlay.prototype.lk = function () {
        _super.prototype.lk.call(this);
        if (this.qc != null) {
            this.qc.h7(false);
        }
    };
    ValueOverlay.prototype.k2 = function (a, b) {
        _super.prototype.k2.call(this, a, b);
        var c = b;
        c.bx();
    };
    ValueOverlay.prototype.qh = function () {
        if (this.qc == null || this.qc.bh == null || isNaN_(this.qv) || this._visibility != 0) {
            return false;
        }
        var a = typeCast(CategoryAxisBase.$, this.qc);
        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.qc);
        },
        enumerable: false,
        configurable: true
    });
    ValueOverlay.prototype.by = function () {
        return new ValueOverlayView(this);
    };
    ValueOverlay.prototype.l4 = function (a) {
        _super.prototype.l4.call(this, a);
        this.qf = typeCast(ValueOverlayView.$, a);
    };
    ValueOverlay.prototype.mp = function (a, b) {
        _super.prototype.mp.call(this, a, b);
        if (!this.e3) {
            this.b1.a2(b);
            return;
        }
        this.b1.a2(b);
        if (this.cy(this.b0) || !this.qh()) {
            return;
        }
        var c = this.getEffectiveViewport1(this.b1);
        var d = this.qc.ei(this.qv, new ScalerParams(0, this.b0.bv, a, this.qc.cg, c));
        this.rd(d, typeCast(ValueOverlayView.$, this.b0));
        this.e3 = false;
    };
    ValueOverlay.prototype.getOffsetValue = function () {
        return 0;
    };
    ValueOverlay.prototype.getCategoryWidth = function () {
        return 0;
    };
    Object.defineProperty(ValueOverlay.prototype, "rw", {
        get: function () {
            return new Thickness(1, this.qm, this.qo, this.qn, this.ql);
        },
        enumerable: false,
        configurable: true
    });
    ValueOverlay.prototype.ag = function () {
        return [this.qc];
    };
    ValueOverlay.prototype.re = function (a, b) {
        if (isNaN_(a)) {
            if (this.qd != null) {
                AxisAnnotationFrameManager.b(this.qd);
                AxisAnnotationFrameManager.d(this, this.qd, true, this.qi, this.qj, b, this.qw, this.qw, this.qe, this.qe);
            }
            return;
        }
        var c = false;
        if (this.qi == null) {
            c = true;
            this.qj = new List$1(Axis.$, 0);
            this.qi = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
        }
        this.qd = new AxisAnnotationFrame();
        var d = this.o5;
        if (d == null) {
            d = this.o9;
        }
        var e = this.qc.co;
        AxisAnnotationFrameManager.c(this.qd, { $type: Point_$type, x: a, y: a }, this, this.ce, this.getEffectiveViewport(), d, this.rt, this.qk, this.rv, this.ru, this.rw, this.qp, this.rt, this.qk, this.rv, this.ru, this.rw, this.qp, !e && this.qg, e && this.qg);
        AxisAnnotationFrameManager.d(this, this.qd, c, this.qi, this.qj, b, this.qw, this.qw, this.qe, this.qe);
    };
    ValueOverlay.prototype.get_isValueOverlay = function () {
        return true;
    };
    ValueOverlay.prototype.q9 = function (a) {
        if (this.qc != null) {
            return this.qc.gc(a);
        }
        return null;
    };
    Object.defineProperty(ValueOverlay.prototype, "rb", {
        get: function () {
            var a = this.q9(this.qv);
            return a != null ? a : stringFormat("{0:0.##}", this.qv);
        },
        enumerable: false,
        configurable: true
    });
    ValueOverlay.$t = markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]);
    ValueOverlay.$$p = markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:qk:rf', [1, DeviceUtils.g(3)], 'AxisAnnotationBackground:rt:rg', [Brush.$, null], 'AxisAnnotationFormatLabel:qe:rh', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:qw:ri', [1, -1], 'AxisAnnotationOutline:ru:rj', [Brush.$, null], 'AxisAnnotationPaddingBottom:ql:rk', [1, NaN], 'AxisAnnotationPaddingLeft:qm:rl', [1, NaN], 'AxisAnnotationPaddingRight:qn:rm', [1, NaN], 'AxisAnnotationPaddingTop:qo:rn', [1, NaN], 'AxisAnnotationStrokeThickness:qp:ro', [1, NaN], 'AxisAnnotationTextColor:rv:rp', [Brush.$, null], 'Axis:qc:rq', [Axis.$, null], 'IsAxisAnnotationEnabled:qg:rr', [0, false], 'Value:qv:rs', [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.o5;
        this.bz.ad = this.e.fy;
        this.bz.ai = this.e.pi;
        this.bz.aj = this.e.pj;
    };
    ValueOverlayView.prototype.bc = function () {
        _super.prototype.bc.call(this);
        var a = this.bo();
        this.bz._stroke = a;
        this.bz.ad = this.e.fy + 3;
        this.bz._stroke = a;
        this.bz.ad = this.e.fy + 3;
    };
    ValueOverlayView.prototype.by = function (a) {
        this.bz.an = a;
        this.aq();
    };
    ValueOverlayView.prototype.bx = function () {
        this.bz.an = null;
        this.aq();
    };
    ValueOverlayView.prototype.a6 = function (a, b) {
        _super.prototype.a6.call(this, a, b);
        if (a.d) {
            a.t(this.bz);
        }
    };
    ValueOverlayView.prototype.al = function (a) {
        _super.prototype.al.call(this, a);
        this.e.a9.exportPathData(a, this.bz, "ValueOverlayPath", []);
    };
    ValueOverlayView.$t = markType(ValueOverlayView, 'ValueOverlayView', SeriesView.$);
    return ValueOverlayView;
}(SeriesView));
export { ValueOverlayView };
