/*
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 { AnnotationLayer } from "./AnnotationLayer";
import { DependencyProperty } from "igniteui-react-core";
import { Base, runOn, delegateCombine, String_$type, enumGetBox, EnumUtil, typeCast, fromEnum, delegateRemove, Point_$type, Date_$type, markType, markDep } from "igniteui-react-core";
import { Series } from "./Series";
import { CalloutPlacementPositionsCollection } from "./CalloutPlacementPositionsCollection";
import { AutoCalloutVisibilityMode_$type } from "./AutoCalloutVisibilityMode";
import { Brush } from "igniteui-react-core";
import { Thickness } from "igniteui-react-core";
import { CalloutCollisionMode_$type } from "./CalloutCollisionMode";
import { FontUtil } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { CalloutLayerFrame } from "./CalloutLayerFrame";
import { HashSet$1 } from "igniteui-react-core";
import { CalloutAnnotationWrapper } from "./CalloutAnnotationWrapper";
import { List$1 } from "igniteui-react-core";
import { LinkedList$1 } from "igniteui-react-core";
import { Dictionary$2 } from "igniteui-react-core";
import { LinkedListNode$1 } from "igniteui-react-core";
import { LabelCollisionManager } from "igniteui-react-core";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { CalloutAnnotation } from "./CalloutAnnotation";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { CalloutLabelUpdatingEventArgs } from "./CalloutLabelUpdatingEventArgs";
import { CalloutSeriesSelectingEventArgs } from "./CalloutSeriesSelectingEventArgs";
import { CalloutStyleUpdatingEventArgs } from "./CalloutStyleUpdatingEventArgs";
import { DeviceUtils } from "igniteui-react-core";
import { CalloutRenderStyleUpdatingEventArgs } from "./CalloutRenderStyleUpdatingEventArgs";
import { LabelCollisionInfo } from "igniteui-react-core";
import { QuadTreeBoundingBox } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { ViewportUtils } from "./ViewportUtils";
import { Size } from "igniteui-react-core";
import { CalloutContentUpdatingEventArgs } from "./CalloutContentUpdatingEventArgs";
import { CalloutKey } from "./CalloutKey";
import { DataContext } from "igniteui-react-core";
import { HashPool$2 } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_ } from "igniteui-react-core";
import { stringIsNullOrEmpty } from "igniteui-react-core";
import { FastItemObjectColumn } from "igniteui-react-core";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { BrushUtil } from "igniteui-react-core";
import { TextBlock } from "igniteui-react-core";
import { Color } from "igniteui-react-core";
import { Line } from "igniteui-react-core";
import { CalloutViewHelper } from "./CalloutViewHelper";
import { Rectangle } from "igniteui-react-core";
import { TranslateTransform } from "igniteui-react-core";
/**
 * @hidden
 */
var CalloutLayer = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(CalloutLayer, _super);
    function CalloutLayer() {
        var _this = _super.call(this) || this;
        _this.calloutStyleUpdating = null;
        _this.calloutRenderStyleUpdating = null;
        _this.xk = null;
        _this.xl = null;
        _this.xm = null;
        _this.xj = null;
        _this.xi = null;
        _this.yc = new HashSet$1(CalloutAnnotationWrapper.$, 0);
        _this.yf = new List$1(CalloutAnnotationWrapper.$, 0);
        _this.yg = new List$1(CalloutAnnotationWrapper.$, 0);
        _this.xa = null;
        _this.w0 = null;
        _this.xg = null;
        _this.yd = new LinkedList$1(CalloutAnnotationWrapper.$);
        _this.ya = new Dictionary$2(CalloutAnnotationWrapper.$, LinkedListNode$1.$.specialize(CalloutAnnotationWrapper.$), 0);
        _this.xs = null;
        _this.abm = new Rect(0, 0, 0, 1, 1);
        _this.xz = false;
        _this.yr = 0;
        _this.abl = Rect.empty;
        _this.xx = false;
        _this.xy = false;
        _this.calloutContentUpdating = null;
        _this.calloutLabelUpdating = null;
        _this.calloutSeriesSelecting = null;
        _this.ye = new List$1(SeriesPointOfInterest.$, 0);
        _this.x1 = false;
        _this.x2 = false;
        _this.yi = 0;
        _this.x0 = false;
        _this.xw = true;
        _this.w2 = 1;
        FastItemObjectColumn.m();
        _this.w0 = null;
        _this.xa = new CalloutPlacementPositionsCollection();
        var a = _this.xa;
        a.collectionChanged = delegateCombine(a.collectionChanged, runOn(_this, _this.z6));
        _this.un = true;
        var b = new CalloutLayerFrame();
        var c = new CalloutLayerFrame();
        var d = new CalloutLayerFrame();
        var e = _this.ji / 1000;
        _this.uf = b;
        _this.ue = c;
        _this.ug = d;
        _this.ab = CalloutLayer.$;
        return _this;
    }
    CalloutLayer.prototype.get_d2 = function () {
        return true;
    };
    CalloutLayer.prototype.z6 = function (a, b) {
        this.aaf();
    };
    CalloutLayer.prototype.aaf = function () {
        this.w0 = this.w1(this.xb);
        this.aac();
    };
    CalloutLayer.prototype.z7 = function (a, b) {
        this.yg.clear();
        this.pp(false);
    };
    CalloutLayer.prototype.no = function (a, b, c, d) {
        _super.prototype.no.call(this, a, b, c, d);
        var e = this.yb();
        switch (a) {
            case 3:
                this.aak(b, e);
                break;
            case 1:
                for (var f = b; f < b + c; f++) {
                    var g = new CalloutAnnotation();
                    var h = new CalloutAnnotationWrapper();
                    h.b = g;
                    h.b.series = this.xf;
                    this.yg.insert(f, h);
                    this.aak(f, e);
                }
                break;
            case 0:
                this.yg.v(b, c);
                break;
            case 2:
                for (var i = b; i < b + c; i++) {
                    this.aak(i, e);
                }
                break;
            case 4:
                this.yg.clear();
                for (var j = 0; j < this.c6.count; j++) {
                    var k = new CalloutAnnotation();
                    var l = new CalloutAnnotationWrapper();
                    l.b = k;
                    l.b.series = this.xf;
                    this.yg.add(l);
                    this.aak(j, e);
                }
                break;
        }
        this.pp(true);
    };
    CalloutLayer.prototype.fp = function (a) {
        return false;
    };
    CalloutLayer.prototype.yb = function () {
        var a = new Dictionary$2(String_$type, Series.$, 0);
        if (this.cy != null) {
            for (var b = 0; b < this.cy.series.count; b++) {
                var c = this.cy.series._inner[b];
                if (c.name != null && !a.containsKey(c.name)) {
                    a.addItem(c.name, c);
                }
            }
        }
        return a;
    };
    CalloutLayer.prototype.aak = function (a, b) {
        var _this = this;
        if (this.xr == null || this.xp == null) {
            return;
        }
        var c = a;
        if (this.xq != null) {
            c = this.xq.item(a);
        }
        var d = this.xr.item(a);
        var e = this.xp.item(a);
        var f = this.yg._inner[a];
        if (this.xo != null) {
            if (f.b.ab != this.xo.item(a)) {
                f.b.key = this.xo.item(a);
            }
        }
        if (this.ya.containsKey(f)) {
            f.b = this.ya.item(f).c.b;
        }
        f.b.xValue = c;
        f.b.yValue = d;
        if (this.calloutLabelUpdating != null) {
            var g = ((function () {
                var $ret = new CalloutLabelUpdatingEventArgs();
                $ret.d = c;
                $ret.e = d;
                $ret.item = _this.c6.item(a);
                return $ret;
            })());
            this.calloutLabelUpdating(this, g);
            if (g.c != null && !Base.equalsStatic(g.c, f.b.ao)) {
                var h = g.c;
                f.b.text = h != null ? h.toString() : "";
            }
        }
        else {
            f.b.text = e != null ? e.toString() : "";
        }
        if (this.xn != null) {
            f.b.content = this.xn.item(a);
        }
        else {
            f.b.content = this.c6.item(a);
        }
        if (this.calloutSeriesSelecting != null) {
            var i = ((function () {
                var $ret = new CalloutSeriesSelectingEventArgs();
                $ret.c = c;
                $ret.d = d;
                $ret.item = _this.c6.item(a);
                return $ret;
            })());
            this.calloutSeriesSelecting(this, i);
            if (i.a != null) {
                f.b.series = i.a;
            }
            else if (i.e != null) {
                if (b.containsKey(i.e)) {
                    f.b.series = b.item(i.e);
                }
            }
        }
        this.aal(f);
    };
    CalloutLayer.prototype.aal = function (a) {
        var b = new Thickness(0, DeviceUtils.g(3));
        if (isNaN_(this.abo.left) || isNaN_(this.abo.top) || isNaN_(this.abo.right) || isNaN_(this.abo.bottom)) {
            b = new Thickness(0, DeviceUtils.g(3));
        }
        else {
            b = this.abo;
        }
        var c = DeviceUtils.g(3);
        if (isNaN_(this.yj)) {
            c = DeviceUtils.g(3);
        }
        else {
            c = this.yj;
        }
        var d = this.abh != null ? this.abh : this.w9.cl(a.b.l);
        var e = this.abk != null ? this.abk : this.w9.co();
        var f = this.abj != null ? this.abj : this.w9.cn(a.b.l);
        var g = this.abi != null ? this.abi : this.w9.cm(a.b.l);
        var h = isNaN_(this.yp) ? 0 : this.yp;
        if (this.x6 && this.calloutStyleUpdating != null) {
            var i = new CalloutStyleUpdatingEventArgs();
            i.item = a.b.aa;
            i.xValue = a.b.ac;
            i.yValue = a.b.ad;
            i.series = a.b.l;
            i.background = d;
            i.textColor = e;
            i.outline = f;
            i.leaderBrush = g;
            i.strokeThickness = h;
            this.calloutStyleUpdating(this, i);
            d = i.background;
            e = i.textColor;
            f = i.outline;
            g = i.leaderBrush;
            h = i.strokeThickness;
        }
        a.b.backgroundPadding = b;
        a.b.backgroundCornerRadius = c;
        a.b.background = d;
        a.b.textColor = e;
        a.b.outline = f;
        a.b.leaderBrush = g;
        a.b.strokeThickness = h;
    };
    CalloutLayer.prototype.ju = function (a, b) {
        var c = this.lv(b);
        if (c == CalloutLayer.$$p[21]) {
            return this.jv(a, b, this.zq);
        }
        if (c == CalloutLayer.$$p[28]) {
            return this.jv(a, b, this.z1);
        }
        if (c == CalloutLayer.$$p[29]) {
            return this.jv(a, b, this.z4);
        }
        if (c == CalloutLayer.$$p[20]) {
            return this.jv(a, b, this.zn);
        }
        if (c == CalloutLayer.$$p[15]) {
            return this.jv(a, b, this.zg);
        }
        return _super.prototype.ju.call(this, a, b);
    };
    Object.defineProperty(CalloutLayer.prototype, "xp", {
        get: function () {
            return this.xk;
        },
        set: function (a) {
            if (this.xk != a) {
                var b = this.xk;
                this.xk = a;
                this.raisePropertyChanged("LabelColumn", b, this.xk);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "xq", {
        get: function () {
            return this.xl;
        },
        set: function (a) {
            if (this.xl != a) {
                var b = this.xl;
                this.xl = a;
                this.raisePropertyChanged("XColumn", b, this.xl);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "xr", {
        get: function () {
            return this.xm;
        },
        set: function (a) {
            if (this.xm != a) {
                var b = this.xm;
                this.xm = a;
                this.raisePropertyChanged("YColumn", b, this.xm);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "xo", {
        get: function () {
            return this.xj;
        },
        set: function (a) {
            if (this.xj != a) {
                var b = this.xj;
                this.xj = a;
                this.raisePropertyChanged("KeyColumn", b, this.xj);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "xn", {
        get: function () {
            return this.xi;
        },
        set: function (a) {
            if (this.xi != a) {
                var b = this.xi;
                this.xi = a;
                this.raisePropertyChanged("ContentColumn", b, this.xi);
            }
        },
        enumerable: false,
        configurable: true
    });
    CalloutLayer.prototype.z9 = function (a, b) {
        if (b.propertyName == CalloutAnnotation.$$p[14] || b.propertyName == CalloutAnnotation.$$p[15]) {
            var c = a.k;
            if (!this.yc.contains(c)) {
                this.yc.add_1(c);
                this.yf.add(c);
                this.pp(false);
            }
        }
    };
    CalloutLayer.prototype.cg = function () {
        return new CalloutLayerView(this);
    };
    CalloutLayer.prototype.o0 = function (a) {
        _super.prototype.o0.call(this, a);
        this.w9 = a;
    };
    Object.defineProperty(CalloutLayer.prototype, "xb", {
        get: function () {
            return this.xa;
        },
        set: function (a) {
            var b = this.xb;
            if (a != b) {
                this.xa = a;
                this.raisePropertyChanged("AllowedPositions", b, this.xb);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "w4", {
        get: function () {
            return EnumUtil.getEnumValue(AutoCalloutVisibilityMode_$type, this.c(CalloutLayer.aa0));
        },
        set: function (a) {
            this.h(CalloutLayer.aa0, enumGetBox(AutoCalloutVisibilityMode_$type, a));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "w3", {
        get: function () {
            return this.w2;
        },
        set: function (a) {
            this.w2 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "abo", {
        get: function () {
            return new Thickness(1, this.yl, this.yn, this.ym, this.yk);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "xh", {
        get: function () {
            if (this.xg == null) {
                this.xg = FontUtil.toFontInfo(this.i4, this.zv);
            }
            return this.xg;
        },
        enumerable: false,
        configurable: true
    });
    CalloutLayer.prototype.vs = function (a, b) {
        if (this.xf == null || this.xf == a) {
            if (!this.at.c) {
                this.pp(b);
            }
        }
    };
    CalloutLayer.prototype.vu = function (a, b) {
        var e_1, _a;
        _super.prototype.vu.call(this, a, b);
        var c = a;
        c.q.clear();
        c.r.clear();
        c.n.clear();
        c.f.clear();
        c.i.clear();
        c.h.clear();
        c.k.clear();
        c.m.clear();
        c.l.clear();
        c.j.clear();
        c.g.clear();
        c.o.clear();
        c.p.clear();
        c.u.clear();
        c.v.clear();
        c.s.clear();
        c.t.clear();
        var d = this.yh();
        var e = new List$1(CalloutAnnotationWrapper.$, 0);
        var f = true;
        if (this.x3) {
            if (this.ul(this.xf)) {
                this.aah(this.xf, c, e);
            }
            else {
                try {
                    for (var _b = __values(fromEnum(this.cy.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                        var g = _c.value;
                        if (this.ul(g)) {
                            if (!g.d6) {
                                if (!g.isVertical) {
                                    f = false;
                                }
                            }
                            this.aah(g, c, e);
                        }
                    }
                }
                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;
                    }
                }
            }
        }
        if (this.x3 && this.w3 == 2) {
            var h = 0;
            var i = 0;
            var j = 1.7976931348623157E+308;
            var k = 1.7976931348623157E+308;
            var l = -1.7976931348623157E+308;
            var m = -1.7976931348623157E+308;
            if (e.count > 0) {
                if (e._inner[0].c != null) {
                    h = e._inner[0].e;
                    i = e._inner[0].f;
                }
                for (var n = 0; n < e.count; n++) {
                    var o = e._inner[n];
                    if (o.c != null) {
                        var p = o.e;
                        var q = o.f;
                        if (p != h) {
                            j = Math.min(j, Math.abs(p - h));
                        }
                        if (q != i) {
                            k = Math.min(k, Math.abs(q - i));
                        }
                        l = Math.max(o.c.l + o.c.l, l);
                        m = Math.max(o.c.k + o.c.k, m);
                    }
                }
                if (f) {
                    if (m > k) {
                        e.clear();
                    }
                }
                else {
                    if (l > j) {
                        e.clear();
                    }
                }
            }
        }
        this.aag(c, d, e);
    };
    CalloutLayer.prototype.qn = function (a, b) {
        _super.prototype.qn.call(this, a, b);
        var c = b.width - this.abm.width;
        var d = b.height - this.abm.height;
        var e = 0;
        if (Math.abs(c) > Math.abs(d)) {
            e = c;
            this.yi = c * this.tw.width;
        }
        else {
            e = d;
            this.yi = d * this.tw.height;
        }
        if (e > 0 && this.yi > 5) {
            this.x2 = true;
        }
        if (e < 0 && this.yi > 5) {
            this.x1 = true;
        }
    };
    CalloutLayer.prototype.qm = function (a, b) {
        _super.prototype.qm.call(this, a, b);
        if (!a.equals1(b)) {
            this.x0 = true;
        }
    };
    Object.defineProperty(CalloutLayer.prototype, "abn", {
        get: function () {
            return this.abl;
        },
        set: function (a) {
            this.abl = a;
        },
        enumerable: false,
        configurable: true
    });
    CalloutLayer.prototype.aag = function (a, b, c) {
        var e_2, _a;
        if (this.cy != null) {
            this.abm = this.cy.tn;
        }
        if (this.tw.isEmpty) {
            return;
        }
        this.abn = new Rect(0, this.tw.left, this.tw.top, this.tw.width, this.tw.height);
        if (this.xs != null && this.zd != null && this.zd != this.xs.ap) {
            this.aab();
        }
        if (this.xs == null) {
            var d = this.xt();
            if (d != null) {
                this.xs = d;
                var e = this.xs;
                e.labelsMoved = delegateCombine(e.labelsMoved, runOn(this, this.z8));
            }
            else {
                var f = this.to(this.cj);
                var g = new Array(2);
                g[0] = 0;
                g[1] = 3;
                if (this.xf != null) {
                    if (this.xf.isVertical) {
                        g = new Array(2);
                        g[0] = 2;
                        g[1] = 1;
                    }
                }
                else {
                    var h = false;
                    if (this.cy != null && this.cy.series.count > 0) {
                        h = true;
                        try {
                            for (var _b = __values(fromEnum(this.cy.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                                var i = _c.value;
                                if (!i.d6) {
                                    if (!i.isVertical) {
                                        h = false;
                                    }
                                }
                            }
                        }
                        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;
                            }
                        }
                    }
                    if (h) {
                        g = new Array(2);
                        g[0] = 2;
                        g[1] = 1;
                    }
                }
                this.xs = new LabelCollisionManager(this.tw.right, this.tw.bottom, this.tw, this.w9.j(), this.yo, this.xu(), g, this.yv(), this.yu(), this.x4, this.w0);
                if (this.zd != null) {
                    this.xs.ap = this.zd;
                    this.xs.an = this;
                }
                var j = this.xs;
                j.labelsMoved = delegateCombine(j.labelsMoved, runOn(this, this.z8));
            }
        }
        if (this.x1) {
            this.x1 = false;
            if (this.xs.al > 2) {
                this.xz = true;
            }
        }
        if (this.x2) {
            this.x2 = false;
            if (this.yi > 5) {
                this.xz = true;
            }
        }
        if (this.x0) {
            this.x0 = false;
            this.xs.a3(this.tw.right, this.tw.bottom, this.tw);
            this.xz = true;
        }
        var k = new HashSet$1(CalloutAnnotationWrapper.$, 0);
        var l = new HashSet$1(CalloutAnnotationWrapper.$, 0);
        var m = new List$1(CalloutAnnotationWrapper.$, 0);
        var n = new List$1(CalloutAnnotationWrapper.$, 0);
        var o = new HashSet$1(CalloutAnnotationWrapper.$, 0);
        for (var p = 0; p < b.count; p++) {
            o.add_1(b._inner[p]);
        }
        for (var q = 0; q < c.count; q++) {
            o.add_1(c._inner[q]);
        }
        var r = this.yd.c;
        while (r != null) {
            var s = r.a;
            if (!o.contains(r.c)) {
                n.add(r.c);
                l.add_1(r.c);
                var t = r.c.b;
                t.propertyChanged = delegateRemove(t.propertyChanged, runOn(this, this.z9));
                this.yd.h(r);
                this.ya.removeItem(r.c);
                this.xs.a2(r.c.c);
            }
            r = s;
        }
        for (var u = 0; u < b.count; u++) {
            if (!this.ya.containsKey(b._inner[u])) {
                this.yd.f(b._inner[u]);
                var v = b._inner[u].b;
                v.propertyChanged = delegateCombine(v.propertyChanged, runOn(this, this.z9));
                this.ya.addItem(b._inner[u], this.yd.d);
                m.add(b._inner[u]);
                k.add_1(b._inner[u]);
                this.xz = true;
            }
        }
        for (var w = 0; w < c.count; w++) {
            if (!this.ya.containsKey(c._inner[w])) {
                this.yd.f(c._inner[w]);
                this.ya.addItem(c._inner[w], this.yd.d);
                var x = c._inner[w].b;
                x.propertyChanged = delegateCombine(x.propertyChanged, runOn(this, this.z9));
                m.add(c._inner[w]);
                k.add_1(c._inner[w]);
                this.xz = true;
            }
        }
        if (this.xx == true) {
            this.xx = false;
            this.xz = true;
        }
        if (this.yf.count > 0) {
            this.xz = true;
            this.yf.clear();
            this.yc.clear();
        }
        r = this.yd.c;
        while (r != null) {
            var y = this.xv(r.c);
            if (y == null) {
                return;
            }
            if (!Base.equalsStatic(y, r.c.c.c)) {
                var z = false;
                if (r.c.c.c == null) {
                    z = true;
                }
                var aa = r.c.c;
                aa.o = y.b;
                aa.p = y.c;
                if (!isNaN_(aa.o) && !isNaN_(aa.p)) {
                    aa.n = y.e;
                    aa.m = y.d;
                    if (aa.b == null) {
                        this.xs.t(aa, false);
                    }
                    if (z) {
                        this.xs.aq(aa);
                    }
                    else {
                        this.xs.az(aa);
                    }
                }
            }
            r = r.a;
        }
        var ab = this.xs.am();
        var ac = this.xs.u();
        if (ac) {
            if (this.xs.q()) {
                this.xz = true;
            }
        }
        if (this.xz && (ab != 0 || ac)) {
            this.xz = false;
            this.yr = 0x7FFFFFFF;
            if (this.zd != null) {
                var ad = true;
                for (var ae = 0; ae < this.cy.series.count; ae++) {
                    var af = this.cy.series._inner[ae];
                    if (af.d6 && typeCast(CalloutLayer.$, af) !== null) {
                        var ag = af;
                        if (ag.zd == this.zd) {
                            if (!ag.abn.equals1(this.xs.a5)) {
                                ad = false;
                                break;
                            }
                        }
                    }
                }
                if (ad) {
                    this.xs.a4();
                }
                else {
                    this.xs.ar();
                    this.xs.as();
                }
            }
            else {
                this.xs.a4();
            }
        }
        else {
            this.xs.as();
        }
        var ah = this.yd.c;
        var ai;
        var aj;
        var ak;
        var al;
        var am;
        var an;
        var ao;
        var ap;
        var aq;
        var ar;
        var as;
        var at;
        var au;
        var av;
        var aw;
        var ax;
        var ay = this.x5;
        while (ah != null) {
            var az = ah.c;
            var a0 = az.b;
            ai = a0.bk;
            aj = a0.bm;
            ak = a0.bl;
            al = a0.backgroundPadding.left;
            am = a0.backgroundPadding.top;
            an = a0.backgroundPadding.right;
            ao = a0.backgroundPadding.bottom;
            aq = a0.backgroundCornerRadius;
            ap = a0.y;
            ar = a0.bn;
            as = a0.ao;
            at = a0.aa;
            var a1 = az.c;
            au = a1.o - (a1.g - a1.l);
            av = a1.p - (a1.h - a1.k);
            aw = a1.g - a1.l;
            ax = a1.h - a1.k;
            if (ay) {
                var a2 = new CalloutRenderStyleUpdatingEventArgs();
                a2.background = ai;
                a2.outline = aj;
                a2.leaderBrush = ak;
                a2.strokeThickness = ap;
                a2.textColor = ar;
                a2.item = at;
                a2.series = a0.l;
                a2.actualPosition = a1.a;
                a2.xValue = a0.ac;
                a2.yValue = a0.ad;
                if (this.calloutRenderStyleUpdating != null) {
                    this.calloutRenderStyleUpdating(this, a2);
                    ai = a2.background;
                    aj = a2.outline;
                    ak = a2.leaderBrush;
                    ap = a2.strokeThickness;
                    ar = a2.textColor;
                }
            }
            a.n.add1(az);
            a.f.add(ai);
            a.i.add(aj);
            a.h.add(ak);
            a.k.add(al);
            a.m.add(am);
            a.l.add(an);
            a.j.add(ao);
            a.g.add(aq);
            a.o.add(ap);
            a.p.add(ar);
            a.q.add1(as);
            a.r.add1(at);
            a.u.add(au);
            a.v.add(av);
            a.s.add(aw);
            a.t.add(ax);
            ah = ah.a;
        }
    };
    CalloutLayer.prototype.aab = function () {
        if (this.xs != null) {
            var a = this.yd.c;
            while (a != null) {
                var b = a.c.c;
                if (b != null) {
                    this.xs.a2(b);
                }
                a = a.a;
            }
            var c = this.xs;
            c.labelsMoved = delegateRemove(c.labelsMoved, runOn(this, this.z8));
            this.xs = null;
        }
        this.aaa();
    };
    CalloutLayer.prototype.xt = function () {
        if (this.cy == null) {
            return null;
        }
        for (var a = 0; a < this.cy.series.count; a++) {
            var b = this.cy.series._inner[a];
            if (b.d6 && typeCast(CalloutLayer.$, b) !== null) {
                var c = b;
                if (c != this) {
                    if (c.zd != null && c.zd == this.zd) {
                        if (c.xs != null) {
                            return c.xs;
                        }
                    }
                }
            }
        }
        return null;
    };
    CalloutLayer.prototype.yu = function () {
        return 20000;
    };
    CalloutLayer.prototype.yv = function () {
        return 300;
    };
    CalloutLayer.prototype.xu = function () {
        switch (this.w6) {
            case 0: return 2;
            case 2: return 1;
            case 3: return 2;
            case 1: return 0;
        }
        return 2;
    };
    CalloutLayer.prototype.z8 = function (a) {
        var b = this.xs.am();
        if (b < this.yr) {
            this.yr = b;
            this.pp(false);
        }
    };
    CalloutLayer.prototype.xv = function (a) {
        var b = this.xf;
        if (a.b.l != null) {
            b = a.b.l;
        }
        if (b == null) {
            for (var c = 0; c < this.cy.series.count; c++) {
                var d = this.cy.series._inner[c];
                if (!d.d6) {
                    b = d;
                    break;
                }
            }
        }
        if (b == null) {
            return null;
        }
        var e = b.ag();
        var f = b.h2();
        var g = null;
        var h = null;
        var i = false;
        for (var j = 0; j < e.length; j++) {
            if (e[j].b9) {
                i = true;
                g = e[j];
            }
            else if (e[j].cm) {
                i = true;
                h = e[j];
            }
            else if (e[j].cp) {
                h = e[j];
            }
            else {
                g = e[j];
            }
        }
        if (g == null || h == null) {
            return null;
        }
        if (!g.co() || !h.co()) {
            return null;
        }
        var k = 0;
        var l = 0;
        if (g.cb && g.categoryMode != 0) {
            if (b.ek) {
                k = b.getOffsetValue();
            }
            else if (b.ec) {
                k = b.getOffsetValue();
            }
        }
        if (h.cb && h.categoryMode != 0) {
            if (b.ec) {
                l = b.getOffsetValue();
            }
        }
        var m = new ScalerParams(0, this.cy.tn, g.kd, g.ch, g.j8());
        m.b = f;
        var n = new ScalerParams(0, this.cy.tn, h.kd, h.ch, h.j8());
        n.b = f;
        var o = 0;
        var p = 0;
        if (i) {
            o = g.ej(this.yq(a.b.ac), m) + k;
            p = h.ej(this.yq(a.b.ad), n) + l;
            var q = o;
            var r = p;
            var s = { $type: Point_$type, x: 0.5, y: 0.5 };
            var t = s.x + (r * Math.cos(q));
            o = ViewportUtils.c(t, m.e, m.d);
            var u = s.y + (r * Math.sin(q));
            p = ViewportUtils.f(u, n.e, n.d);
        }
        else {
            o = g.ej(this.yq(a.b.ac), m) + k;
            p = h.ej(this.yq(a.b.ad), n) + l;
        }
        var v = new QuadTreeBoundingBox();
        v.b = o;
        v.c = p;
        v.e = 3;
        v.d = 3;
        v.g = a.b;
        return v;
    };
    CalloutLayer.prototype.yq = function (a) {
        if (typeCast(Date_$type, a) !== null) {
            return a.getTime();
        }
        if (a == null) {
            return 0;
        }
        return a;
    };
    CalloutLayer.prototype.yh = function () {
        var a = new List$1(CalloutAnnotationWrapper.$, 0);
        for (var b = 0; b < this.yg.count; b++) {
            if (stringIsNullOrEmpty(this.yg._inner[b].b.ao)) {
                continue;
            }
            if (this.yg._inner[b].c == null) {
                var c = new LabelCollisionInfo();
                this.yg._inner[b].c = c;
                var d = this.w9.cq(this.yw(this.yg._inner[b]), this.yg._inner[b].b.backgroundPadding);
                c.k = d.height / 2;
                c.l = d.width / 2;
            }
            var e = this.xv(this.yg._inner[b]);
            if (e == null || e.b < this.tw.left || e.b > this.tw.right || e.c < this.tw.top || e.c > this.tw.bottom) {
                continue;
            }
            a.add(this.yg._inner[b]);
        }
        return a;
    };
    CalloutLayer.prototype.yw = function (a) {
        return a.b.ao;
    };
    CalloutLayer.prototype.ul = function (a) {
        if (!_super.prototype.ul.call(this, a)) {
            return false;
        }
        if (this.zs != null) {
            if (a.ep) {
                var b = a.lu();
                if (!Base.equalsStatic(this.zs, b)) {
                    return false;
                }
            }
            else {
                if (!Base.equalsStatic(this.zs, a.name)) {
                    return false;
                }
            }
        }
        return true;
    };
    CalloutLayer.prototype.oo = function () {
        _super.prototype.oo.call(this);
        if (!this.at.c && !this.dj()) {
            return;
        }
        if (this.xw) {
            this.xw = false;
            this.aad();
        }
        if (this.dj()) {
            this.aaj(this.ug, false);
        }
        else {
            this.aaj(this.ue, false);
        }
    };
    CalloutLayer.prototype.aae = function () {
        if (!this.xy) {
            this.xy = true;
            this.pp(true);
        }
    };
    CalloutLayer.prototype.aah = function (a, b, c) {
        var d = false;
        if (this.xy) {
            this.xy = false;
            d = true;
        }
        if (!a.fs && a.ds(this.ye, this.x9, this.x7, this.ys)) {
            var e = this.ye;
            var _loop_1 = function (f) {
                var g = e._inner[f];
                var h = g.a != null ? g.a.item : null;
                var i = g.a.item != null ? g.a.item : g.a;
                var j = a;
                var k = new CalloutKey(i, j);
                var l = new CalloutAnnotationWrapper();
                var m = new CalloutAnnotation();
                l.b = m;
                m.key = k;
                var n = false;
                if (this_1.ya.containsKey(l)) {
                    l = this_1.ya.item(l).c;
                    m = l.b;
                    n = d;
                }
                else {
                    n = true;
                }
                var o = m.ac;
                var p = m.ad;
                if (this_1.yq(o) != this_1.yq(g.b)) {
                    m.xValue = g.b;
                }
                if (this_1.yq(p) != this_1.yq(g.c)) {
                    m.yValue = g.c;
                }
                m.series = a;
                var q = false;
                if (g.d != m.ay) {
                    m.ay = g.d;
                    q = true;
                }
                if (n || q) {
                    if (this_1.calloutLabelUpdating != null) {
                        var r = ((function () {
                            var $ret = new CalloutLabelUpdatingEventArgs();
                            $ret.d = m.ac;
                            $ret.e = m.ad;
                            $ret.item = h;
                            $ret.a = a;
                            $ret.f = a.name;
                            return $ret;
                        })());
                        this_1.calloutLabelUpdating(this_1, r);
                        if (r.c != null && !Base.equalsStatic(r.c, l.b.ao)) {
                            var s = r.c;
                            l.b.text = s != null ? s.toString() : "";
                        }
                    }
                    else {
                        if (g.d != null) {
                            m.text = g.d;
                        }
                    }
                }
                if (m.ao == null) {
                    return "continue";
                }
                if (n || q) {
                    if (this_1.calloutContentUpdating != null) {
                        var t = ((function () {
                            var $ret = new CalloutContentUpdatingEventArgs();
                            $ret.c = m.ac;
                            $ret.d = m.ad;
                            $ret.item = h;
                            $ret.a = i;
                            return $ret;
                        })());
                        this_1.calloutContentUpdating(this_1, t);
                        if (t.a != null && t.a != l.b.aa) {
                            l.b.content = t.a;
                        }
                    }
                    else {
                        if (i != null && i != l.b.aa) {
                            l.b.content = i;
                        }
                    }
                }
                if (n) {
                    this_1.aal(l);
                }
                if (l.c == null) {
                    var u = new LabelCollisionInfo();
                    l.c = u;
                    var v = this_1.w9.cq(this_1.yw(l), l.b.backgroundPadding);
                    u.k = v.height / 2;
                    u.l = v.width / 2;
                }
                var w = this_1.xv(l);
                if (w == null || w.b < this_1.tw.left || w.b > this_1.tw.right || w.c < this_1.tw.top || w.c > this_1.tw.bottom) {
                    return "continue";
                }
                l.e = w.b;
                l.f = w.c;
                c.add(l);
            };
            var this_1 = this;
            for (var f = 0; f < this.ye.count; f++) {
                _loop_1(f);
            }
        }
    };
    CalloutLayer.prototype.bx = function () {
        return 1;
    };
    CalloutLayer.prototype.au = function (a, b) {
        var c = this.xs.f(a, b);
        if (c == null) {
            return null;
        }
        return c.u;
    };
    CalloutLayer.prototype.f4 = function (a, b) {
        if (this.xs == null) {
            return false;
        }
        return this.xs.f(a, b) != null;
    };
    CalloutLayer.prototype.aaj = function (a, b) {
        var e_3, _a;
        var c = 0;
        var d = new HashSet$1(CalloutAnnotationWrapper.$, 0);
        for (c = 0; c < a.q.count; c++) {
            var e = a.n._inner[c];
            if (isNaN_(a.u._inner[c]) || isNaN_(a.v._inner[c])) {
                continue;
            }
            var f = this.w9.cb.item(e);
            d.add_1(e);
            if (f.h != a.q._inner[c]) {
                f.h = a.q._inner[c];
                var g = f.u();
            }
            f.e = a.o._inner[c];
            f.m = a.f._inner[c];
            f.p = a.p._inner[c];
            f.o = f.e > 0 ? a.i._inner[c] : this.cj.bt();
            f.n = a.h._inner[c];
            f.x = new Thickness(1, a.k._inner[c], a.m._inner[c], a.l._inner[c], a.j._inner[c]);
            f.d = a.g._inner[c];
            this.w9.cj(f, Math.min(a.s._inner[c], a.s._inner[c] + a.u._inner[c]), Math.min(a.t._inner[c], a.t._inner[c] + a.v._inner[c]));
            this.w9.ck(f, e, a.r._inner[c]);
            f.r = { $type: Point_$type, x: a.u._inner[c], y: a.v._inner[c] };
        }
        var h = new List$1(CalloutAnnotationWrapper.$, 0);
        try {
            for (var _b = __values(fromEnum(this.w9.cb.c)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var i = _c.value;
                if (!d.contains(i)) {
                    h.add(i);
                }
            }
        }
        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;
            }
        }
        for (var j = 0; j < h.count; j++) {
            this.w9.cb.h(h._inner[j]);
        }
    };
    CalloutLayer.prototype.vx = function (a, b) {
        _super.prototype.vx.call(this, a, b);
        if (this.dj()) {
            this.aaj(this.ug, true);
        }
        else {
            this.aaj(this.ue, false);
        }
    };
    CalloutLayer.prototype.fm = function () {
        return true;
    };
    CalloutLayer.prototype.o8 = function (a, b, c, d) {
        _super.prototype.o8.call(this, a, b, c, d);
        switch (b) {
            case CalloutLayer.$$p[24]:
                this.xg = null;
                this.w9.ci();
                this.pp(true);
                break;
            case CalloutLayer.$$p[22]:
            case CalloutLayer.$$p[23]:
                this.pp(true);
                break;
            case CalloutLayer.$$p[14]:
                this.pp(true);
                break;
            case "SeriesViewer":
                if (c != null) {
                    var e = c;
                    e.seriesAnimating = delegateRemove(e.seriesAnimating, runOn(this, this.aai));
                }
                if (d != null) {
                    var f = d;
                    f.seriesAnimating = delegateCombine(f.seriesAnimating, runOn(this, this.aai));
                }
                if (d == null) {
                    this.aab();
                }
                break;
            case "AutoCalloutVisibilityMode":
                this.w3 = this.w5();
                this.aac();
                break;
            case "AllowedPositions":
                if (c != null) {
                    var g = c;
                    g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.z6));
                }
                if (d != null) {
                    var h = d;
                    h.collectionChanged = delegateCombine(h.collectionChanged, runOn(this, this.z6));
                }
                this.w0 = this.w1(this.xb);
                this.aac();
                break;
            case CalloutLayer.$$p[16]:
            case CalloutLayer.$$p[17]:
            case CalloutLayer.$$p[1]:
            case CalloutLayer.$$p[6]:
            case CalloutLayer.$$p[5]:
            case CalloutLayer.$$p[25]:
            case CalloutLayer.$$p[26]:
            case CalloutLayer.$$p[19]:
            case CalloutLayer.$$p[18]:
            case CalloutLayer.$$p[8]:
            case CalloutLayer.$$p[10]:
            case CalloutLayer.$$p[9]:
            case CalloutLayer.$$p[7]:
            case CalloutLayer.$$p[12]:
            case CalloutLayer.$$p[13]:
                this.aac();
                break;
            case CalloutLayer.$$p[21]:
                if (this.c6 != null) {
                    this.c6.deregisterColumn(this.xp);
                    this.xp = this.c5(this.zq);
                }
                break;
            case "LabelColumn":
                this.aac();
                break;
            case CalloutLayer.$$p[15]:
                if (this.c6 != null) {
                    this.c6.deregisterColumn(this.xn);
                    this.xn = this.c5(this.zg);
                }
                break;
            case "ContentColumn":
                this.aac();
                break;
            case CalloutLayer.$$p[28]:
                if (this.c6 != null) {
                    this.c6.deregisterColumn(this.xq);
                    this.xq = stringIsNullOrEmpty(this.z1) == false ? this.c5(this.z1) : null;
                }
                break;
            case "XColumn":
                this.aac();
                break;
            case CalloutLayer.$$p[29]:
                if (this.c6 != null) {
                    this.c6.deregisterColumn(this.xr);
                    this.xr = this.c5(this.z4);
                }
                break;
            case "YColumn":
                this.aac();
                break;
            case CalloutLayer.$$p[20]:
                if (this.c6 != null) {
                    this.c6.deregisterColumn(this.xo);
                    this.xo = this.c5(this.zn);
                }
                break;
            case "KeyColumn":
                this.aac();
                break;
            case "FastItemsSource":
                this.xx = true;
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.xp);
                    c.deregisterColumn(this.xn);
                    c.deregisterColumn(this.xq);
                    c.deregisterColumn(this.xr);
                    c.deregisterColumn(this.xo);
                    this.xp = null;
                    this.xn = null;
                    this.xq = null;
                    this.xr = null;
                    this.xo = null;
                    this.yg.clear();
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.xp = this.c5(this.zq);
                    this.xn = this.c5(this.zg);
                    if (stringIsNullOrEmpty(this.z1) == false) {
                        this.xq = this.c5(this.z1);
                    }
                    this.xr = this.c5(this.z4);
                    this.xo = this.c5(this.zn);
                }
                this.aac();
                break;
        }
    };
    CalloutLayer.prototype.w5 = function () {
        if (this.w4 == 0) {
            return 1;
        }
        return this.w4;
    };
    CalloutLayer.prototype.w1 = function (a) {
        if (a == null || a.count == 0) {
            return null;
        }
        var b = new Array(a.count);
        for (var c = 0; c < a.count; c++) {
            b[c] = a._inner[c];
        }
        return b;
    };
    CalloutLayer.prototype.aai = function (a) {
        if (a.d6) {
            return;
        }
        if ((a == this.xf || this.xf == null) && this.x3) {
            this.pp(false);
        }
    };
    CalloutLayer.prototype.aac = function () {
        if (this.xw == false) {
            this.xw = true;
            this.pp(false);
        }
    };
    CalloutLayer.prototype.aaa = function () {
        this.w9.cb.clear();
        this.yd.g();
        this.ya.clear();
    };
    CalloutLayer.prototype.aad = function () {
        if (this.xr == null || this.xp == null) {
            var a = this.yd.c;
            while (a != null) {
                this.aal(a.c);
                a = a.a;
            }
            return;
        }
        var b = this.yb();
        for (var c = 0; c < this.xr.count; c++) {
            var d = void 0;
            if (this.yg.count <= c) {
                var e = new CalloutAnnotation();
                d = new CalloutAnnotationWrapper();
                d.b = e;
                d.b.series = this.xf;
                this.yg.add(d);
            }
            else {
                d = this.yg._inner[c];
            }
            this.aak(c, b);
        }
    };
    CalloutLayer.$t = markType(CalloutLayer, 'CalloutLayer', AnnotationLayer.$);
    CalloutLayer.aa0 = DependencyProperty.i("AutoCalloutVisibilityMode", AutoCalloutVisibilityMode_$type, CalloutLayer.$, new PropertyMetadata(2, enumGetBox(AutoCalloutVisibilityMode_$type, 0), function (a, b) { return a.raisePropertyChanged("AutoCalloutVisibilityMode", b.oldValue, b.newValue); }));
    CalloutLayer.$$p = markDep(DependencyProperty, PropertyMetadata, CalloutLayer, 'raisePropertyChanged', ['AutoCalloutLabelPrecision:ys:aam', [1, 5], 'CalloutBackground:abh:aan', [Brush.$, null], 'CalloutCollisionMode:w6:aao', [CalloutCollisionMode_$type, enumGetBox(CalloutCollisionMode_$type, 3)], 'CalloutCornerRadius:yj:aap', [1, NaN], 'CalloutInterpolatedValuePrecision:yt:aaq', [1, -1], 'CalloutLeaderBrush:abi:aar', [Brush.$, null], 'CalloutOutline:abj:aas', [Brush.$, null], 'CalloutPaddingBottom:yk:aat', [1, NaN], 'CalloutPaddingLeft:yl:aau', [1, NaN], 'CalloutPaddingRight:ym:aav', [1, NaN], 'CalloutPaddingTop:yn:aaw', [1, NaN], 'CalloutPositionPadding:yo:aax', [1, 10], 'CalloutStrokeThickness:yp:aay', [1, NaN], 'CalloutTextColor:abk:aaz', [Brush.$, null], 'CollisionChannel:zd:aa1', [2, null], 'ContentMemberPath:zg:aa2', [2, null], 'IsAutoCalloutBehaviorEnabled:x3:aa3', [0, false], 'IsCalloutOffsettingEnabled:x4:aa4', [0, true], 'IsCustomCalloutRenderStyleEnabled:x5:aa5', [0, false], 'IsCustomCalloutStyleEnabled:x6:aa6', [0, false], 'KeyMemberPath:zn:aa7', [2, null], 'LabelMemberPath:zq:aa8', [2, null], 'TargetSeriesName:zs:aa9', [2, null], 'TargetSeries:xf:aba', [Series.$, null], 'TextStyle:zv:abb', [2, null], 'UseInterpolatedValueForAutoCalloutLabels:x7:abc', [0, false], 'UseSeriesColorForOutline:x8:abd', [0, false], 'UseValueForAutoCalloutLabels:x9:abe', [0, true], 'XMemberPath:z1:abf', [2, null], 'YMemberPath:z4:abg', [2, null]]);
    return CalloutLayer;
}(AnnotationLayer));
export { CalloutLayer };
/**
 * @hidden
 */
var CalloutLayerView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(CalloutLayerView, _super);
    function CalloutLayerView(a) {
        var _this = _super.call(this, a) || this;
        _this.b7 = null;
        _this.cc = null;
        _this.cb = null;
        _this.cd = NaN;
        _this.b8 = null;
        _this.b7 = a;
        _this.cc = new List$1(CalloutView.$, 0);
        return _this;
    }
    CalloutLayerView.prototype.au = function () {
        var _this = this;
        _super.prototype.au.call(this);
        this.cb = ((function () {
            var $ret = new HashPool$2(CalloutAnnotationWrapper.$, CalloutView.$);
            $ret.create = runOn(_this, _this.b9);
            $ret.activate = runOn(_this, _this.cf);
            $ret.disactivate = runOn(_this, _this.ch);
            $ret.destroy = runOn(_this, _this.cg);
            return $ret;
        })());
    };
    CalloutLayerView.prototype.b9 = function () {
        var a = new CalloutView(this);
        this.cc.add(a);
        return a;
    };
    CalloutLayerView.prototype.cf = function (a) {
        a.y = 0;
    };
    CalloutLayerView.prototype.ch = function (a) {
        a.y = 1;
    };
    CalloutLayerView.prototype.cg = function (a) {
        this.cc.remove(a);
    };
    CalloutLayerView.prototype.cp = function (a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.m(a, 0.1);
    };
    CalloutLayerView.prototype.a8 = function (a, b) {
        _super.prototype.a8.call(this, a, b);
        a.ad(this.ca());
        if (a.d && !b) {
            for (var c = 0; c < this.cc.count; c++) {
                var d = this.cc._inner[c];
                if (d.y == 0) {
                    d.j(a);
                }
            }
        }
    };
    CalloutLayerView.prototype.ca = function () {
        if (this.b7.xh != null) {
            return this.b7.xh;
        }
        return this.e.cy.getFontInfo();
    };
    CalloutLayerView.prototype.an = function (a) {
        _super.prototype.an.call(this, a);
        for (var b = 0; b < this.cc.count; b++) {
            var c = this.cc._inner[b];
            if (c.y != 0) {
                continue;
            }
            c.i(this.b7, this.ca(), a);
        }
    };
    CalloutLayerView.prototype.cr = function (a) {
        this.k.ad(this.ca());
        this.cd = this.ce();
        var b = this.k.ah(a, this.cd, true);
        return new Size(1, b.c, b.b);
    };
    CalloutLayerView.prototype.ce = function () {
        var a = this.ca();
        if (isNaN_(this.cd)) {
            var b = FontUtil.getCurrentFontHeight(this.e.cy.cv.j.ae, a);
            this.cd = b;
        }
        return this.cd;
    };
    CalloutLayerView.prototype.cq = function (a, b) {
        if (this.b8 == null) {
            this.b8 = new CalloutView(this);
        }
        this.b8.h = a;
        this.b8.x = b;
        var c = this.b8.u();
        this.b8.h = null;
        return c;
    };
    CalloutLayerView.prototype.cj = function (a, b, c) {
        a.f = b;
        a.g = c;
    };
    CalloutLayerView.prototype.ck = function (a, b, c) {
        a.k(this.e, b, c);
    };
    CalloutLayerView.prototype.cl = function (a) {
        if (a != null) {
            return this.cp(a.sx);
        }
        return this.e.sx;
    };
    CalloutLayerView.prototype.co = function () {
        return ((function () {
            var $ret = new Brush();
            $ret.color = Color.u(255, 255, 255, 255);
            return $ret;
        })());
    };
    CalloutLayerView.prototype.cn = function (a) {
        if (this.b7.x8) {
            if (a != null) {
                return this.cp(a.sx);
            }
        }
        return ((function () {
            var $ret = new Brush();
            $ret.color = Color.u(255, 255, 255, 255);
            return $ret;
        })());
    };
    CalloutLayerView.prototype.cm = function (a) {
        if (a != null) {
            return this.cp(a.ss);
        }
        return this.e.ss;
    };
    CalloutLayerView.prototype.ci = function () {
        this.cd = NaN;
    };
    CalloutLayerView.$t = markType(CalloutLayerView, 'CalloutLayerView', AnnotationLayerView.$);
    return CalloutLayerView;
}(AnnotationLayerView));
export { CalloutLayerView };
/**
 * @hidden
 */
var CalloutView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(CalloutView, _super);
    function CalloutView(a) {
        var _this = _super.call(this) || this;
        _this.a = null;
        _this.y = 0;
        _this.l = null;
        _this.t = null;
        _this.q = { $type: Point_$type, x: 0, y: 0 };
        _this.s = null;
        _this.w = new Thickness(0, 0);
        _this.v = null;
        _this.c = 0;
        _this.f = 0;
        _this.g = 0;
        _this.b = null;
        _this.s = new Line();
        _this.s.ab = false;
        _this.s._stroke = ((function () {
            var $ret = new Brush();
            $ret.color = Color.u(255, 0, 0, 0);
            return $ret;
        })());
        _this.s.ad = 2;
        _this.l = new TextBlock();
        _this.t = new Rectangle();
        _this.t.ad = 0;
        _this.a = a;
        _this.y = 0;
        return _this;
    }
    CalloutView.prototype.j = function (a) {
        a.aa();
        a.ag(this.f, this.g);
        var b = new TranslateTransform();
        b.j = this.v.left;
        b.k = this.v.top;
        this.t.j = b;
        a.s(this.s);
        a.aa();
        this.t.width = this.l.m + this.w.left + this.w.right;
        this.t.height = this.l.l + this.w.top + this.w.bottom;
        this.t.ap = this.c;
        this.t.aq = this.c;
        a.k(this.t.j);
        a.w(this.t);
        this.l.ag = true;
        this.l.o = this.w.top;
        this.l.n = this.w.left;
        a.x(this.l);
        a.z();
        a.z();
    };
    Object.defineProperty(CalloutView.prototype, "r", {
        get: function () {
            return this.q;
        },
        set: function (a) {
            if (this.q.x != a.x || this.q.y != a.y) {
                var b = this.u();
                var c = b.height;
                var d = b.width;
                this.q = a;
                var e = CalloutViewHelper.b(this.r, d, c, this.s);
                this.v = e;
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "p", {
        get: function () {
            return this.l.ao;
        },
        set: function (a) {
            this.l.ao = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "o", {
        get: function () {
            return this.t._stroke;
        },
        set: function (a) {
            this.t._stroke = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "n", {
        get: function () {
            return this.s._stroke;
        },
        set: function (a) {
            this.s._stroke = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "m", {
        get: function () {
            return this.t._fill;
        },
        set: function (a) {
            this.t._fill = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "e", {
        get: function () {
            return this.t.ad;
        },
        set: function (a) {
            this.t.ad = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "x", {
        get: function () {
            return this.w;
        },
        set: function (a) {
            this.w = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "d", {
        get: function () {
            return this.c;
        },
        set: function (a) {
            this.c = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "h", {
        get: function () {
            return this.l.al;
        },
        set: function (a) {
            if (a == null) {
                this.l.al = "";
            }
            else {
                this.l.al = a.toString();
            }
            var b = this.u();
            var c = b.height;
            var d = b.width;
            var e = CalloutViewHelper.b(this.r, d, c, this.s);
            this.v = e;
        },
        enumerable: false,
        configurable: true
    });
    CalloutView.prototype.u = function () {
        var a = this.a.cr(this.l);
        this.l.m = a.width;
        this.l.l = a.height;
        return new Size(1, a.width + this.w.left + this.w.right, a.height + this.w.top + this.w.bottom);
    };
    CalloutView.prototype.k = function (a, b, c) {
        if (this.b == null) {
            this.b = new DataContext();
        }
        this.b.series = a;
        this.b.item = c;
        if (b.c != null) {
            b.c.u = this.b;
        }
    };
    CalloutView.prototype.i = function (a, b, c) {
        a.a9.exportCalloutData(this.f, this.g, this.v.left, this.v.top, c, this.t, this.l, b, this.s, "callout", ["Main", "Callout"]);
    };
    CalloutView.$t = markType(CalloutView, 'CalloutView');
    return CalloutView;
}(Base));
export { CalloutView };
