/*
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 * as tslib_1 from "tslib";
import { Base, Type, typeCast, Delegate_$type, runOn, markType, getInstanceType, delegateRemove, delegateCombine, Point_$type, fromEnum, Number_$type, IEnumerable_$type, EnumUtil, Array_$type, enumGetBox } from "igniteui-react-core/ES5/type";
import { ServiceProvider_Spark } from "./ServiceProvider_Spark";
import { Dictionary$2 } from "igniteui-react-core/ES5/Dictionary$2";
import { MessageChannel_Spark } from "./MessageChannel_Spark";
import { AxisRenderMessage_Spark } from "./AxisRenderMessage_Spark";
import { ContainerResizedMessage_Spark } from "./ContainerResizedMessage_Spark";
import { ViewportChangedMessage_Spark } from "./ViewportChangedMessage_Spark";
import { PixelRatioMessage_Spark } from "./PixelRatioMessage_Spark";
import { RenderingContext } from "igniteui-react-core/ES5/RenderingContext";
import { FontUtil } from "igniteui-react-core/ES5/FontUtil";
import { Brush } from "igniteui-react-core/ES5/Brush";
import { Color } from "igniteui-react-core/ES5/Color";
import { Line } from "igniteui-react-core/ES5/Line";
import { TextBlock } from "igniteui-react-core/ES5/TextBlock";
import { SparklineAxisVisualData } from "./SparklineAxisVisualData";
import { LineVisualData } from "igniteui-react-core/ES5/LineVisualData";
import { AppearanceHelper } from "igniteui-react-core/ES5/AppearanceHelper";
import { Visibility_$type } from "igniteui-react-core/ES5/Visibility";
import { ClearMessage_Spark } from "./ClearMessage_Spark";
import { ISchedulableRender_$type } from "igniteui-react-core/ES5/ISchedulableRender";
import { CanvasRenderScheduler } from "igniteui-react-core/ES5/CanvasRenderScheduler";
import { Path } from "igniteui-react-core/ES5/Path";
import { PolygonMessage_Spark } from "./PolygonMessage_Spark";
import { ColumnMessage_Spark } from "./ColumnMessage_Spark";
import { WinLossColumnMessage_Spark } from "./WinLossColumnMessage_Spark";
import { MarkerMessage_Spark } from "./MarkerMessage_Spark";
import { NormalRangeMessage_Spark } from "./NormalRangeMessage_Spark";
import { TrendLineMessage_Spark } from "./TrendLineMessage_Spark";
import { TooltipMessage_Spark } from "./TooltipMessage_Spark";
import { ToooltipTemplateMessage_Spark } from "./ToooltipTemplateMessage_Spark";
import { ContainerMessage_Spark } from "./ContainerMessage_Spark";
import { BrushChangedMessage_Spark } from "./BrushChangedMessage_Spark";
import { VisibilityMessage_Spark } from "./VisibilityMessage_Spark";
import { NumberChangedMessage_Spark } from "./NumberChangedMessage_Spark";
import { ContainerSizeChangedMessage_Spark } from "./ContainerSizeChangedMessage_Spark";
import { MouseMoveMessage_Spark } from "./MouseMoveMessage_Spark";
import { MouseLeaveMessage_Spark } from "./MouseLeaveMessage_Spark";
import { CanvasGestureDOMEventProxy } from "igniteui-react-core/ES5/CanvasGestureDOMEventProxy";
import { CanvasViewRenderer } from "igniteui-react-core/ES5/CanvasViewRenderer";
import { Rect } from "igniteui-react-core/ES5/Rect";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { TranslateTransform } from "igniteui-react-core/ES5/TranslateTransform";
import { DeviceUtils } from "igniteui-react-core/ES5/DeviceUtils";
import { GeometryGroup } from "igniteui-react-core/ES5/GeometryGroup";
import { EllipseGeometry } from "igniteui-react-core/ES5/EllipseGeometry";
import { PathGeometry } from "igniteui-react-core/ES5/PathGeometry";
import { PathFigure } from "igniteui-react-core/ES5/PathFigure";
import { LineSegment } from "igniteui-react-core/ES5/LineSegment";
import { RectangleGeometry } from "igniteui-react-core/ES5/RectangleGeometry";
import { SparklineToolTipContext } from "./SparklineToolTipContext";
import { DataContext } from "igniteui-react-core/ES5/DataContext";
import { SparklineVisualData } from "./SparklineVisualData";
import { RectData } from "igniteui-react-core/ES5/RectData";
import { PathVisualData } from "igniteui-react-core/ES5/PathVisualData";
import { SparklineDisplayType_$type } from "./SparklineDisplayType";
import { truncate, isNaN_, isInfinity } from "igniteui-react-core/ES5/number";
import { SparkFrame } from "./SparkFrame";
import { TrendLineType_$type } from "igniteui-react-core/ES5/TrendLineType";
import { TrendCalculators } from "igniteui-react-core/ES5/TrendCalculators";
import { LeastSquaresFit } from "igniteui-react-core/ES5/LeastSquaresFit";
import { DependencyObject } from "igniteui-react-core/ES5/DependencyObject";
import { IFastItemsSourceProvider_$type } from "igniteui-react-core/ES5/IFastItemsSourceProvider";
import { IFastItemsSource_$type } from "igniteui-react-core/ES5/IFastItemsSource";
import { DependencyProperty } from "igniteui-react-core/ES5/DependencyProperty";
import { PropertyChangedMessage_Spark } from "./PropertyChangedMessage_Spark";
import { FastItemsSource } from "igniteui-react-core/ES5/FastItemsSource";
import { DataChangedMessage_Spark } from "./DataChangedMessage_Spark";
import { NotifyCollectionChangedEventArgs } from "igniteui-react-core/ES5/NotifyCollectionChangedEventArgs";
import { FastItemsSourceReference } from "igniteui-react-core/ES5/FastItemsSourceReference";
import { PropertyMetadata } from "igniteui-react-core/ES5/PropertyMetadata";
import { UnknownValuePlotting_$type } from "igniteui-react-core/ES5/UnknownValuePlotting";
import { Control } from "igniteui-react-core/ES5/Control";
/**
 * @hidden
 */
var HorizontalAxisView = /** @class */ (function (_super) {
    tslib_1.__extends(HorizontalAxisView, _super);
    function HorizontalAxisView(a) {
        var _this = _super.call(this) || this;
        _this.j = null;
        _this.w = null;
        _this.m = null;
        _this.l = null;
        _this.s = 0;
        _this.v = 0;
        _this.u = 0;
        _this.k = null;
        _this.r = -1;
        _this.ag = null;
        _this.af = null;
        _this.ah = null;
        _this.a = ["border-top-width", "border-top-color", "color"];
        _this.n = false;
        _this.q = 1;
        _this.g = null;
        _this.o = new Dictionary$2(Type.$, Delegate_$type, 0);
        _this.d = null;
        _this.c = null;
        _this.p.item(AxisRenderMessage_Spark.$, function (b) { return _this.ac(typeCast(AxisRenderMessage_Spark.$, b)); });
        _this.p.item(ContainerResizedMessage_Spark.$, function (b) { return _this.y(typeCast(ContainerResizedMessage_Spark.$, b)); });
        _this.p.item(ViewportChangedMessage_Spark.$, function (b) { return _this.ae(typeCast(ViewportChangedMessage_Spark.$, b)); });
        _this.p.item(PixelRatioMessage_Spark.$, function (b) { return _this.ab(typeCast(PixelRatioMessage_Spark.$, b)); });
        _this.j = a;
        return _this;
    }
    HorizontalAxisView.prototype.b = function () {
        if (!this.n) {
            this.n = true;
            this.k.a("ui-sparkline-axis-x", this.a);
        }
        return this.a;
    };
    HorizontalAxisView.prototype.t = function () {
        var a = this.r;
        if (a >= 0) {
            return a;
        }
        var b = this.b()[0];
        if (b != null) {
            a = parseInt(b);
        }
        this.r = a = (a < 1) ? 1 : a;
        return a;
    };
    Object.defineProperty(HorizontalAxisView.prototype, "h", {
        get: function () {
            return this.g;
        },
        set: function (a) {
            var b = this.g;
            this.g = a;
            this.k = a.getService("View");
            this.aa(b, this.g);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(HorizontalAxisView.prototype, "p", {
        get: function () {
            return this.o;
        },
        set: function (a) {
            this.o = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(HorizontalAxisView.prototype, "f", {
        get: function () {
            return this.d;
        },
        set: function (a) {
            this.d = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(HorizontalAxisView.prototype, "e", {
        get: function () {
            return this.c;
        },
        set: function (a) {
            this.c = a;
        },
        enumerable: true,
        configurable: true
    });
    HorizontalAxisView.prototype.z = function (a) {
        var _this = this;
        var b;
        if (((function () { var c = _this.p.tryGetValue(getInstanceType(a), b); b = c.p1; return c.ret; })())) {
            b(a);
        }
    };
    HorizontalAxisView.prototype.aa = function (a, b) {
        if (a != null) {
            this.f.detachTarget(runOn(this, this.z));
        }
        if (b != null) {
            this.f = b.getService("RenderingMessages");
            this.e = b.getService("InteractionMessages");
            this.f.attachTarget(runOn(this, this.z));
        }
    };
    HorizontalAxisView.prototype.y = function (a) {
        this.w = a.j;
        this.m = a.b;
        this.l = this.k.n("ui-sparkline-axis-x");
        if (this.l == null) {
            this.l = FontUtil.getFont(a.h);
        }
        if (this.m != null) {
            this.m.ac(this.l);
        }
        this.s = FontUtil.getCurrentFontHeight(a.h, this.l);
        if (this.j != null && this.j.e5 != 1) {
            a.d = a.d - this.s;
            a.e = this.t();
        }
    };
    HorizontalAxisView.prototype.ae = function (a) {
        this.v = this.w.width();
        this.u = this.s + this.t();
    };
    HorizontalAxisView.prototype.ac = function (a) {
        this.ad(a.c);
    };
    HorizontalAxisView.prototype.ad = function (a) {
        this.ah = null;
        var b = (!a || this.j == null) ? null : this.m;
        if (b == null || !b.d) {
            return;
        }
        b.k(0, 0, this.v, this.u);
        if (this.l != null) {
            b.ac(this.l);
        }
        if (this.q != 1) {
            b.z();
            b.aa(this.q, this.q);
        }
        var c = this.t(), d = c / 2;
        var e = this.j.ar == null || this.j.ar.count == 0;
        if (e) {
            this.u = 0;
        }
        var f = e ? null : this.x(this.j.ar.item(0));
        var g = f == null ? "" : f.toString();
        this.ag = new TextBlock();
        this.ag.ak = g;
        this.ag.n = 2;
        this.af = new TextBlock();
        var h = e ? null : this.x(this.j.ar.item(this.j.ar.count - 1));
        this.af.ak = g = h == null ? "" : h.toString();
        this.af.o = this.ag.o = c;
        this.af.n = this.v - b.f(g) - 4;
        var i = this.j.eu;
        var j = i == null ? null : i._fill;
        var k = new Color();
        var l = true;
        if (i != null) {
            l = false;
            k = i.color;
        }
        i = new Brush();
        if (l) {
            i._fill = (this.a[2] == null) ? "#000000" : this.a[2];
        }
        else {
            i.color = k;
        }
        this.ag.am = this.af.am = i;
        b.w(this.ag);
        b.w(this.af);
        if (c < 0.5) {
            return;
        }
        i = new Brush();
        if (j == null) {
            j = this.a[1];
        }
        i._fill = (j == null) ? "#000000" : j;
        this.ah = new Line();
        this.ah.aj = 0;
        this.ah.ak = this.w.width();
        this.ah.al = d;
        this.ah.am = d;
        this.ah._stroke = i;
        this.ah.ac = c;
        b.r(this.ah);
        if (this.q != 1) {
            b.y();
        }
    };
    HorizontalAxisView.prototype.x = function (dataItem_) {
        if (this.j.at()) {
            return this.j.ct(dataItem_);
        }
        var label_ = this.j.bn;
        return (typeof dataItem_ != 'undefined') ? dataItem_ : '';
        ;
    };
    HorizontalAxisView.prototype.i = function () {
        var a = new SparklineAxisVisualData();
        if (this.ah != null) {
            a.axisLine = new LineVisualData(1, "HorizontalAxisLine", this.ah);
        }
        var b = this.l;
        if (this.ag != null) {
            a.minLabel = AppearanceHelper.c(this.ag, this.l);
        }
        if (this.af != null) {
            a.maxLabel = AppearanceHelper.c(this.af, this.l);
        }
        return a;
    };
    HorizontalAxisView.prototype.ab = function (a) {
        this.q = a.b;
    };
    HorizontalAxisView.$t = markType(HorizontalAxisView, 'HorizontalAxisView');
    return HorizontalAxisView;
}(Base));
export { HorizontalAxisView };
/**
 * @hidden
 */
var VerticalAxisView = /** @class */ (function (_super) {
    tslib_1.__extends(VerticalAxisView, _super);
    function VerticalAxisView(a) {
        var _this = _super.call(this) || this;
        _this.ad = null;
        _this.ac = null;
        _this.al = null;
        _this.ak = null;
        _this.am = null;
        _this.w = -1;
        _this.u = -1;
        _this.j = null;
        _this.aa = null;
        _this.m = null;
        _this.l = null;
        _this.t = 0;
        _this.v = 0;
        _this.z = 0;
        _this.y = 0;
        _this.k = null;
        _this.s = -1;
        _this.a = ["border-top-width", "border-top-color", "color", "text-align"];
        _this.n = false;
        _this.g = null;
        _this.p = new Dictionary$2(Type.$, Delegate_$type, 0);
        _this.d = null;
        _this.c = null;
        _this.r = 1;
        _this.q.item(AxisRenderMessage_Spark.$, function (b) { return _this.ai(typeCast(AxisRenderMessage_Spark.$, b)); });
        _this.q.item(ContainerResizedMessage_Spark.$, function (b) { return _this.ae(typeCast(ContainerResizedMessage_Spark.$, b)); });
        _this.q.item(ViewportChangedMessage_Spark.$, function (b) { return _this.aj(typeCast(ViewportChangedMessage_Spark.$, b)); });
        _this.q.item(PixelRatioMessage_Spark.$, function (b) { return _this.ah(typeCast(PixelRatioMessage_Spark.$, b)); });
        _this.j = a;
        return _this;
    }
    VerticalAxisView.prototype.b = function () {
        if (!this.n) {
            this.n = true;
            this.k.a("ui-sparkline-axis-y", this.a);
        }
        return this.a;
    };
    VerticalAxisView.prototype.x = function () {
        var a = this.s;
        if (a >= 0) {
            return a;
        }
        var b = this.b()[0];
        if (b != null) {
            a = parseInt(b);
        }
        this.s = a = (a < 1) ? 1 : a;
        return a;
    };
    Object.defineProperty(VerticalAxisView.prototype, "h", {
        get: function () {
            return this.g;
        },
        set: function (a) {
            var b = this.g;
            this.g = a;
            this.k = a.getService("View");
            this.ag(b, this.g);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(VerticalAxisView.prototype, "q", {
        get: function () {
            return this.p;
        },
        set: function (a) {
            this.p = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(VerticalAxisView.prototype, "f", {
        get: function () {
            return this.d;
        },
        set: function (a) {
            this.d = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(VerticalAxisView.prototype, "e", {
        get: function () {
            return this.c;
        },
        set: function (a) {
            this.c = a;
        },
        enumerable: true,
        configurable: true
    });
    VerticalAxisView.prototype.af = function (a) {
        var _this = this;
        var b;
        if (((function () { var c = _this.q.tryGetValue(getInstanceType(a), b); b = c.p1; return c.ret; })())) {
            b(a);
        }
    };
    VerticalAxisView.prototype.ag = function (a, b) {
        if (a != null) {
            this.f.detachTarget(runOn(this, this.af));
        }
        if (b != null) {
            this.f = b.getService("RenderingMessages");
            this.e = b.getService("InteractionMessages");
            this.f.attachTarget(runOn(this, this.af));
        }
    };
    VerticalAxisView.prototype.ae = function (a) {
        this.aa = a.k;
        this.m = a.c;
        this.l = this.k.n("ui-sparkline-axis-y");
        if (this.l == null) {
            this.l = FontUtil.getFont(a.h);
        }
        if (this.m != null) {
            this.m.ac(this.l);
        }
        this.t = FontUtil.getCurrentFontHeight(a.h, this.l);
        if (this.j != null && this.j.fc != 1) {
            this.o(false);
            a.g = a.g - this.v;
            a.f = this.x();
        }
    };
    VerticalAxisView.prototype.aj = function (a) {
        this.z = this.v + this.x();
        this.y = this.aa.height();
    };
    VerticalAxisView.prototype.ai = function (a) {
        if (this.o(a.c)) {
            var b = new ClearMessage_Spark();
            b.c = true;
            this.f.sendMessage(b);
        }
    };
    VerticalAxisView.prototype.o = function (a) {
        this.am = null;
        if (this.j == null || this.m == null || !this.m.d || (a && this.ak == null)) {
            return false;
        }
        var b = this.m;
        if (a) {
            b.k(0, 0, this.z, this.y);
        }
        var c = false;
        if (b != null && this.l != null) {
            b.ac(this.l);
        }
        if (!a) {
            this.al = new TextBlock();
            this.ak = new TextBlock();
            var d = this.ab(this.j.a0);
            this.al.ak = this.ad = d == null ? "" : d.toString();
            var e = this.ab(this.j.az);
            this.ak.ak = this.ac = e == null ? "" : e.toString();
            if (b != null) {
                this.w = b.f(this.ad) + 3;
                if (this.w > this.v) {
                    c = true;
                    this.v = this.w;
                }
                this.u = b.f(this.ac) + 3;
                if (this.u > this.v) {
                    c = true;
                    this.v = this.u;
                }
            }
            if (!c) {
                var f = Math.max(this.w, this.u);
                if (f < this.v) {
                    this.v = f;
                    c = true;
                }
            }
            if (c) {
                this.z = this.v;
            }
        }
        else if (b != null) {
            if (this.r != 1) {
                b.z();
                b.aa(this.r, this.r);
            }
            var g = this.j.e2;
            var h = 1;
            var i = g == null ? null : g._fill;
            var j = this.b()[3];
            if (j == "left") {
                h = 0;
            }
            else if (j == "center") {
                h = 0.5;
            }
            this.ak.o = 2;
            this.ak.n = (this.v - this.u) * h + 1;
            this.al.n = (this.v - this.w) * h + 1;
            this.al.o = this.y - this.t - 2;
            var k = new Color();
            var l = true;
            if (g != null) {
                k = g.color;
                l = false;
            }
            g = new Brush();
            if (l) {
                g._fill = (this.a[2] == null) ? "#000000" : this.a[2];
            }
            else {
                g.color = k;
            }
            this.al.am = this.ak.am = g;
            b.w(this.al);
            b.w(this.ak);
            var m = this.x(), n = m / 2;
            if (m >= 0.5) {
                g = new Brush();
                if (i == null) {
                    i = this.a[1];
                }
                g._fill = (i == null) ? "#000000" : i;
                this.am = new Line();
                this.am.aj = this.z - n;
                this.am.ak = this.z - n;
                this.am.al = 0;
                this.am.am = this.y;
                this.am._stroke = g;
                this.am.ac = m;
                b.r(this.am);
            }
            if (this.r != 1) {
                b.y();
            }
        }
        return c;
    };
    VerticalAxisView.prototype.ab = function (dataItem_) {
        if (this.j.at()) {
            return this.j.ct(dataItem_);
        }
        var label_ = this.j.bp;
        return (typeof dataItem_ != 'undefined') ? dataItem_ : '';
        ;
    };
    VerticalAxisView.prototype.i = function () {
        var a = new SparklineAxisVisualData();
        if (this.am != null) {
            a.axisLine = new LineVisualData(1, "VerticalAxisLine", this.am);
        }
        if (this.al != null) {
            a.minLabel = AppearanceHelper.c(this.al, this.l);
        }
        if (this.ak != null) {
            a.maxLabel = AppearanceHelper.c(this.ak, this.l);
        }
        return a;
    };
    VerticalAxisView.prototype.ah = function (a) {
        this.r = a.b;
    };
    VerticalAxisView.$t = markType(VerticalAxisView, 'VerticalAxisView');
    return VerticalAxisView;
}(Base));
export { VerticalAxisView };
/**
 * @hidden
 */
var XamSparklineView = /** @class */ (function (_super) {
    tslib_1.__extends(XamSparklineView, _super);
    function XamSparklineView() {
        var _this = _super.call(this) || this;
        _this.bl = null;
        _this.bk = null;
        _this.ae = null;
        _this.af = null;
        _this.ag = null;
        _this.ah = null;
        _this.o = null;
        _this.p = null;
        _this.q = null;
        _this.m = null;
        _this.t = false;
        _this.b = new Array(6);
        _this.x = -1;
        _this.bu = new Path();
        _this.bs = new Path();
        _this.bv = new Path();
        _this.bt = new Path();
        _this.bq = new Path();
        _this.br = new Path();
        _this.bp = new Path();
        _this.bn = new Path();
        _this.bm = new Path();
        _this.bo = new Path();
        _this.i = null;
        _this.e = null;
        _this.f = null;
        _this.u = new Dictionary$2(Type.$, Delegate_$type, 0);
        _this.k = null;
        _this.r = false;
        _this.ai = null;
        _this.d = null;
        _this.c = null;
        _this.s = false;
        _this.w = 1;
        _this.ad = null;
        var a = _this.v;
        a.item(ClearMessage_Spark.$, function (b) { return _this.aj(typeCast(ClearMessage_Spark.$, b)); });
        a.item(PolygonMessage_Spark.$, function (b) { return _this.ba(typeCast(PolygonMessage_Spark.$, b)); });
        a.item(ColumnMessage_Spark.$, function (b) { return _this.a3(typeCast(ColumnMessage_Spark.$, b)); });
        a.item(WinLossColumnMessage_Spark.$, function (b) { return _this.bh(typeCast(WinLossColumnMessage_Spark.$, b)); });
        a.item(MarkerMessage_Spark.$, function (b) { return _this.a6(typeCast(MarkerMessage_Spark.$, b)); });
        a.item(NormalRangeMessage_Spark.$, function (b) { return _this.bb(typeCast(NormalRangeMessage_Spark.$, b)); });
        a.item(TrendLineMessage_Spark.$, function (b) { return _this.be(typeCast(TrendLineMessage_Spark.$, b)); });
        a.item(TooltipMessage_Spark.$, function (b) { return _this.bc(typeCast(TooltipMessage_Spark.$, b)); });
        a.item(ToooltipTemplateMessage_Spark.$, function (b) { return _this.bd(typeCast(ToooltipTemplateMessage_Spark.$, b)); });
        a.item(ContainerMessage_Spark.$, function (b) { return _this.ak(typeCast(ContainerMessage_Spark.$, b)); });
        a.item(PixelRatioMessage_Spark.$, function (b) { return _this.au(typeCast(PixelRatioMessage_Spark.$, b)); });
        a.item(BrushChangedMessage_Spark.$, function (b) { return _this.a1(typeCast(BrushChangedMessage_Spark.$, b)); });
        a.item(ContainerResizedMessage_Spark.$, function (b) { return _this.as(); });
        a.item(VisibilityMessage_Spark.$, function (b) { return _this.bg(typeCast(VisibilityMessage_Spark.$, b)); });
        a.item(NumberChangedMessage_Spark.$, function (b) { return _this.a9(typeCast(NumberChangedMessage_Spark.$, b)); });
        a.item(ContainerSizeChangedMessage_Spark.$, function (b) { return _this.as(); });
        _this.c = new CanvasRenderScheduler();
        _this.c.l(_this);
        return _this;
    }
    XamSparklineView.prototype.au = function (a) {
        this.w = a.b;
    };
    Object.defineProperty(XamSparklineView.prototype, "j", {
        get: function () {
            return this.i;
        },
        set: function (a) {
            var b = this.i;
            this.i = a;
            this.at(b, this.i);
            this.k = null;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(XamSparklineView.prototype, "g", {
        get: function () {
            return this.e;
        },
        set: function (a) {
            this.e = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(XamSparklineView.prototype, "h", {
        get: function () {
            return this.f;
        },
        set: function (a) {
            this.f = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(XamSparklineView.prototype, "v", {
        get: function () {
            return this.u;
        },
        set: function (a) {
            this.u = a;
        },
        enumerable: true,
        configurable: true
    });
    XamSparklineView.prototype.at = function (a, b) {
        if (a != null) {
            this.h.detachTarget(runOn(this, this.ar));
            this.g = null;
        }
        if (b != null) {
            this.h = b.getService("RenderingMessages");
            this.g = b.getService("InteractionMessages");
            this.h.attachTarget(runOn(this, this.ar));
            this.a0(this.g);
        }
    };
    XamSparklineView.prototype.a0 = function (a) {
        this.g = a;
    };
    XamSparklineView.prototype.ar = function (a) {
        var _this = this;
        var b;
        if (((function () { var c = _this.v.tryGetValue(getInstanceType(a), b); b = c.p1; return c.ret; })())) {
            b(a);
        }
    };
    Object.defineProperty(XamSparklineView.prototype, "l", {
        get: function () {
            if (this.k == null) {
                this.k = this.j.getService("Controller");
            }
            return this.k;
        },
        enumerable: true,
        configurable: true
    });
    XamSparklineView.prototype.az = function (a, b, c) {
        var d = new MouseMoveMessage_Spark();
        d.position = a;
        this.g.sendMessage(d);
    };
    XamSparklineView.prototype.ay = function (a) {
        var b = new MouseLeaveMessage_Spark();
        this.g.sendMessage(b);
    };
    XamSparklineView.prototype.a1 = function (a) {
        this.a2(a.b, a.c, null, -1, -1);
    };
    XamSparklineView.prototype.a2 = function (a, b, c, d, e) {
        var f = null;
        var g = true, h = true;
        switch (a) {
            case "sparkpath":
            case XamSparkline.$$p[0]:
                f = this.bu;
                break;
            case "negativesparkpath":
            case XamSparkline.$$p[27]:
                f = this.bs;
                break;
            case "markers":
            case XamSparkline.$$p[22]:
                f = this.bq;
                break;
            case "firstmarker":
            case XamSparkline.$$p[3]:
                f = this.bm;
                break;
            case "lastmarker":
            case XamSparkline.$$p[15]:
                f = this.bo;
                break;
            case "highmarker":
            case XamSparkline.$$p[7]:
                f = this.bn;
                break;
            case "lowmarker":
            case XamSparkline.$$p[19]:
                f = this.bp;
                break;
            case "negativemarkers":
            case XamSparkline.$$p[28]:
                f = this.br;
                break;
            case "trendline":
            case XamSparkline.$$p[36]:
                f = this.bv;
                h = false;
                break;
            case "range":
            case XamSparkline.$$p[31]:
                f = this.bt;
                g = false;
                break;
        }
        if (f == null) {
            return;
        }
        if (b == null && c != null) {
            b = new Brush();
            b._fill = c;
        }
        if (b != null) {
            if (h && (c == null || f._fill == null)) {
                f._fill = b;
            }
            if (g && (c == null || f._stroke == null)) {
                f._stroke = b;
            }
        }
        if (d > 0 && d < 1) {
            f._opacity = d;
        }
        if (e > 0 && (c == null || f.ac <= 0)) {
            f.ac = e;
        }
        this.aq();
    };
    XamSparklineView.prototype.bg = function (a) {
        switch (a.b) {
            case XamSparkline.$$p[24]:
                this.bq._visibility = a.c;
                break;
            case XamSparkline.$$p[5]:
                this.bm._visibility = a.c;
                break;
            case XamSparkline.$$p[17]:
                this.bo._visibility = a.c;
                break;
            case XamSparkline.$$p[9]:
                this.bn._visibility = a.c;
                break;
            case XamSparkline.$$p[21]:
                this.bp._visibility = a.c;
                break;
            case XamSparkline.$$p[30]:
                this.br._visibility = a.c;
                break;
            case XamSparkline.$$p[34]:
                this.bt._visibility = a.c;
                break;
            case XamSparkline.$$p[35]:
                this.t = a.c == 0;
                break;
        }
        this.aq();
    };
    XamSparklineView.prototype.a9 = function (a) {
        var b = a.b;
        if (b <= 0) {
            return;
        }
        switch (a.c) {
            case XamSparkline.$$p[18]:
                this.bu.ac = this.bs.ac = b;
                break;
            case XamSparkline.$$p[38]:
                this.bv.ac = b;
                break;
        }
        this.aq();
    };
    XamSparklineView.prototype.ak = function (a) {
        if (a.b == null) {
            if (this.m != null) {
                this.m.ao();
                var b = this.m;
                b.onMouseLeave = delegateRemove(b.onMouseLeave, runOn(this, this.ay));
                var c = this.m;
                c.onMouseOver = delegateRemove(c.onMouseOver, runOn(this, this.az));
                this.m = null;
            }
            if (this.ad != null) {
                window.removeEventListener("resize", this.ad, false);
                this.ad = null;
            }
            this.ae = null;
            this.af = null;
            this.ag = null;
            this.ah = null;
            this.o = this.p = this.q = null;
            this.c.j(null);
            return;
        }
        var d = a.b;
        this.c.j(d);
        this.ae = d;
        this.ae.rootWrapper.setStyleProperty("position", "relative");
        this.af = this.ae.createElement("canvas");
        this.af.setStyleProperty("position", "absolute");
        this.ag = this.ae.createElement("canvas");
        this.ag.setStyleProperty("position", "absolute");
        this.ah = this.ae.createElement("canvas");
        this.ah.setStyleProperty("position", "absolute");
        this.ae.append(this.af);
        this.ae.append(this.ag);
        this.ae.append(this.ah);
        this.o = new RenderingContext(new CanvasViewRenderer(), this.ae.get2DCanvasContext(this.af));
        this.p = new RenderingContext(new CanvasViewRenderer(), this.ae.get2DCanvasContext(this.ag));
        this.q = new RenderingContext(new CanvasViewRenderer(), this.ae.get2DCanvasContext(this.ah));
        this.m = new CanvasGestureDOMEventProxy(this.af, this.ae, false);
        var e = this.m;
        e.onMouseLeave = delegateCombine(e.onMouseLeave, runOn(this, this.ay));
        var f = this.m;
        f.onMouseOver = delegateCombine(f.onMouseOver, runOn(this, this.az));
        this.m.aj = function (g) { return false; };
        this.ao();
        this.as();
    };
    XamSparklineView.prototype.ao = function () {
        var a = ["sparkpath", "negativesparkpath", "trendline", "markers", "firstmarker", "lastmarker", "highmarker", "lowmarker", "negativemarkers", "range"];
        var b = ["#B1BFC9", "#798995", "#2070a0", "#4F606C", "#374650", "#162C3B", "#162C3B", "#162C3B", "#862C3B", "#a0a0a0"];
        for (var c = 0; c < 10; c++) {
            var d = a[c];
            var e = ["background-color", "opacity", "border-top-width"];
            this.a("ui-sparkline-" + d, e);
            var f = XamSparklineView.ac(e[2], (c < 3) ? (c < 2 ? 2 : 1.5) : -1);
            if (c > 2 && c < 9) {
                this.b[c - 3] = f;
            }
            this.a2(d, null, (e[0] == null) ? b[c] : e[0], XamSparklineView.ac(e[1], -1), c < 3 ? f : -1);
        }
    };
    XamSparklineView.ac = function (v_, a) {
        var d_ = (v_ == null || v_.length < 1) ? null : parseFloat(v_);
        return (d_ == null || d_.toString() == "NaN") ? a : d_;
    };
    XamSparklineView.prototype.a = function (a, b) {
        this.ae.startCSSQuery();
        for (var c = 0; c < b.length; c++) {
            b[c] = this.ae.getCssDefaultPropertyValue(a, b[c]);
        }
        this.ae.endCSSQuery();
        return b;
    };
    XamSparklineView.prototype.as = function () {
        if (this.ae == null || this.r) {
            return;
        }
        this.r = true;
        var a = this.ae.rootWrapper.width(), b = this.ae.rootWrapper.height();
        var c, d, e;
        c = this.af;
        d = this.ag;
        e = this.ah;
        var f = new ContainerResizedMessage_Spark();
        f.g = a;
        f.d = b;
        f.b = this.p;
        f.h = this.ae;
        f.c = this.q;
        f.f = 0;
        f.e = 0;
        f.j = d;
        f.i = c;
        f.k = e;
        this.h.sendMessage(f);
        var g = f.e, h = f.f, i = f.g - h, j = f.d - g;
        var k = i, l = a - i, m = j, n = b - j;
        c.setStyleProperty("width", k.toString() + "px");
        c.setStyleProperty("height", m.toString() + "px");
        c.setAttribute("width", (k * this.w).toString());
        c.setAttribute("height", (m * this.w).toString());
        c.setStyleProperty("marginLeft", l + "px");
        k = (i + h);
        this.ax(d, k, n, k * this.w, n * this.w);
        d.setStyleProperty("marginTop", m + "px");
        d.setStyleProperty("marginLeft", (a - i - h).toString() + "px");
        this.ax(e, l, m, l * this.w, m * this.w);
        this.bl = new Rect(0, 0, 0, i, j);
        if (this.m != null) {
            this.m.bd = this.bl;
        }
        this.bf();
        var o = new ViewportChangedMessage_Spark();
        o.newLeft = this.bl.left;
        o.newTop = this.bl.top;
        o.newHeight = this.bl.height;
        o.newWidth = this.bl.width;
        this.h.sendMessage(o);
        this.r = false;
    };
    XamSparklineView.prototype.al = function (a) {
        if (a) {
            this.x = -1;
        }
        else if (this.x < 0) {
            this.bf();
        }
    };
    XamSparklineView.prototype.bf = function () {
        var a = this.bl.left;
        var b = this.bl.width;
        var c = this.bl.height;
        var d = this.aa(true);
        var e = new Rect(0, a + d, d, b - d * 2, c - d * 2);
        var f = new ViewportChangedMessage_Spark();
        f.newLeft = e.left;
        f.newTop = e.top;
        f.newHeight = e.height;
        f.newWidth = e.width;
        this.bk = e;
        this.g.sendMessage(f);
    };
    XamSparklineView.prototype.aj = function (a) {
        if (Rect.l_op_Equality(this.bl, null)) {
            return;
        }
        switch (a.b) {
            case 2:
                this.bq.aj = null;
                this.bm.aj = null;
                this.bo.aj = null;
                this.bn.aj = null;
                this.bp.aj = null;
                this.br.aj = null;
                break;
            case 8:
                this.bt.aj = null;
                break;
            case 1:
                this.bu.aj = null;
                this.bs.aj = null;
                break;
            case 4:
                this.am(null);
                break;
            case 16:
                this.bv.aj = null;
                break;
        }
        if (a.c) {
            this.as();
        }
    };
    XamSparklineView.prototype.aa = function (a) {
        if (a) {
            this.x = -1;
        }
        var b = this.x;
        if (b >= 0) {
            return b;
        }
        b = 0;
        var c = this.l.q;
        if (c.e8 == 0) {
            b = this.ab(b, c.a9, 0);
        }
        if (c.e3 == 0) {
            b = this.ab(b, c.a2, 1);
        }
        if (c.e6 == 0) {
            b = this.ab(b, c.a4, 2);
        }
        if (c.e4 == 0) {
            b = this.ab(b, c.a3, 3);
        }
        if (c.e7 == 0) {
            b = this.ab(b, c.a8, 4);
        }
        if (c.e9 == 0) {
            b = this.ab(b, c.be, 5);
        }
        this.x = b;
        return b;
    };
    XamSparklineView.prototype.ab = function (a, b, c) {
        if (b >= 0) {
            return b > a ? b : a;
        }
        return this.b[c] > a ? this.b[c] : a;
    };
    XamSparklineView.prototype.a6 = function (a) {
        this.a7(this.bq, a.e, a.k, 0);
        this.a7(this.br, a.f, a.l, 5);
        this.a7(this.bp, a.d, a.j, 4);
        this.a7(this.bn, a.c, a.h, 3);
        this.a8(this.bm, a.m, a.g, 1);
        this.a8(this.bo, a.n, a.i, 2);
        this.aq();
    };
    XamSparklineView.prototype.a8 = function (a, b, c, d) {
        var e = ((function () {
            var $ret = new List$1(Point_$type, 0);
            $ret.add(b);
            return $ret;
        })());
        this.a7(a, e, c, d);
    };
    XamSparklineView.prototype.a7 = function (a, b, c, d) {
        if (c < 0) {
            c = this.b[d];
        }
        a.aj = this.bj(b, c < 0.1 ? DeviceUtils.g(3) : c);
        if (this.l.q.am != 3) {
            var e = new TranslateTransform();
            e.j = this.l.o.d;
            a.j = e;
        }
        else {
            a.j = null;
        }
    };
    XamSparklineView.prototype.bj = function (a, b) {
        var e_1, _a;
        var c = new GeometryGroup();
        c.b = 1;
        var d = this.bl.right;
        var e = this.bl.bottom;
        try {
            for (var _b = tslib_1.__values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var f = _c.value;
                if ((!f)) {
                    continue;
                }
                if (f.x < 0 || f.y < 0 || f.x > d || f.y > e) {
                    continue;
                }
                var g = new EllipseGeometry();
                g.b = b;
                g.c = b;
                g.d = f;
                c.c.add(g);
            }
        }
        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; }
        }
        return c;
    };
    XamSparklineView.prototype.ba = function (a) {
        var e_2, _a;
        var b = new PathGeometry();
        var c = this.l.q.am == 1;
        try {
            for (var _b = tslib_1.__values(fromEnum(a.points)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var d = _c.value;
                var e = d.length;
                if (e == 0) {
                    continue;
                }
                var f = new PathFigure();
                f._isClosed = f._isFilled = c;
                f._startPoint = d[0];
                for (var g = 1; g < e; g++) {
                    var h = new LineSegment(1);
                    h.c = d[g];
                    f._segments.add(h);
                }
                b.b.add(f);
            }
        }
        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; }
        }
        this.bu.aj = b;
        this.aq();
    };
    XamSparklineView.prototype.bi = function (a, b) {
        var e_3, _a;
        var c = typeCast(WinLossColumnMessage_Spark.$, b);
        var d = typeCast(ColumnMessage_Spark.$, b);
        var e = new GeometryGroup();
        var f = c != null ? c.i : d.i;
        var g = c != null ? c.h : d.h;
        var h = f * 0.1;
        try {
            for (var _b = tslib_1.__values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var i = _c.value;
                var j = f * 2 - h * 2;
                var k = Math.abs(g - i.y);
                var l = i.x + h;
                var m = (i.y > g ? g : i.y);
                var n = new RectangleGeometry();
                n.d = new Rect(0, l, m, j, k);
                e.c.add(n);
            }
        }
        catch (e_3_1) { e_3 = { error: e_3_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
            }
            finally { if (e_3) throw e_3.error; }
        }
        return e;
    };
    XamSparklineView.prototype.a3 = function (a) {
        this.a4(this.bu, a.d, a);
        this.a4(this.bs, a.g, a);
        this.aq();
    };
    XamSparklineView.prototype.a5 = function (a, b, c) {
        var d = ((function () {
            var $ret = new List$1(Point_$type, 0);
            $ret.add(b);
            return $ret;
        })());
        this.a4(a, d, c);
    };
    XamSparklineView.prototype.a4 = function (a, b, c) {
        a.aj = this.bi(b, c);
    };
    XamSparklineView.prototype.bh = function (a) {
        this.a4(this.bu, a.d, a);
        this.a4(this.bs, a.g, a);
        this.aq();
    };
    XamSparklineView.prototype.bb = function (a) {
        var b = new RectangleGeometry();
        b.d = new Rect(0, a.k, a.l, a.j, a.i);
        this.bt.aj = b;
        this.aq();
    };
    XamSparklineView.prototype.be = function (a) {
        if (a.points.length == 0) {
            return;
        }
        var b = new PathGeometry();
        var c = new PathFigure();
        c._isClosed = c._isFilled = false;
        c._startPoint = a.points[0];
        var d = a.points.length;
        for (var e = 1; e < d; e++) {
            var f = new LineSegment(1);
            f.c = a.points[e];
            c._segments.add(f);
        }
        b.b.add(c);
        this.bv.aj = b;
        this.aq();
    };
    XamSparklineView.prototype.bd = function (a) {
        this.ai = a.template;
    };
    XamSparklineView.prototype.bc = function (a) {
        if (!this.t) {
            this.am(null);
            return;
        }
        var b = truncate(Math.round(a.xOffset - 10));
        var c = truncate(Math.round(a.yOffset - 10));
        b = truncate(Math.round(b * this.w));
        c = truncate(Math.round(c * this.w));
        var d = this.o.a(b, c);
        if (d[3] > 0) {
            this.am(a);
        }
        else {
            this.am(null);
        }
    };
    XamSparklineView.prototype.am = function (a) {
        var x_ = 0, y_ = 0;
        var v_ = null, t_ = null, i_ = this.ae;
        {
            if (a != null) {
                t_ = this.ai;
                x_ = a.xOffset + 6;
                y_ = a.yOffset + 6;
                var b = a.context;
                var f_ = b.first, l_ = b.last, o_ = b.low, h_ = b.high;
                v_ = { First: f_, Last: l_, Low: o_, High: h_ };
            }
            var ren_ = this.ae;
            if (this.d == null) {
                this.d = new DataContext();
            }
            var dc_ = this.d;
            dc_.item = v_;
            dc_.series = this;
            var tt_ = this.ai;
            if (tt_ != null) {
                if (v_ != null) {
                    tt_.updateToolTip(dc_);
                    tt_.setRawPosition(x_, y_);
                }
                else {
                    tt_.hideToolTip();
                }
            }
        }
    };
    Object.defineProperty(XamSparklineView.prototype, "isDirty", {
        get: function () {
            return this.s;
        },
        set: function (a) {
            this.s = a;
        },
        enumerable: true,
        configurable: true
    });
    XamSparklineView.prototype.aq = function () {
        if (!this.isDirty) {
            this.isDirty = true;
            this.c.o(this.o, null);
        }
    };
    XamSparklineView.prototype.undirty = function (a) {
        this.s = false;
        this.av();
    };
    Object.defineProperty(XamSparklineView.prototype, "index", {
        get: function () {
            return 10;
        },
        enumerable: true,
        configurable: true
    });
    XamSparklineView.prototype.aw = function (a, b) {
        b.s(a);
    };
    XamSparklineView.prototype.av = function () {
        var a = this.o;
        if (a != null && a.d) {
            if (this.w != 1) {
                a.z();
                a.aa(this.w, this.w);
            }
            a.k(this.bl.left, this.bl.top, this.bl.width, this.bl.height);
            a.s(this.bu);
            a.s(this.bs);
            this.aw(this.bq, a);
            this.aw(this.br, a);
            this.aw(this.bn, a);
            this.aw(this.bp, a);
            this.aw(this.bm, a);
            this.aw(this.bo, a);
            a.s(this.bt);
            a.s(this.bv);
            if (this.w != 1) {
                a.y();
            }
        }
        var b = new AxisRenderMessage_Spark();
        b.c = true;
        this.h.sendMessage(b);
        this.postRender();
    };
    XamSparklineView.prototype.postRender = function () {
    };
    XamSparklineView.prototype.an = function (a) {
        a.viewport = new RectData(this.bl.left, this.bl.top, this.bl.width, this.bl.height);
        a.marginViewport = new RectData(this.bk.left, this.bk.top, this.bk.width, this.bk.height);
        a.sparkPath = new PathVisualData(1, "SparkPath", this.bu);
        a.negativeSparkPath = new PathVisualData(1, "NegativeSparkPath", this.bs);
        a.trendLinePath = new PathVisualData(1, "TrendLinePath", this.bv);
        a.rangePath = new PathVisualData(1, "RangePath", this.bt);
        a.markersPath = new PathVisualData(1, "MarkersPath", this.bq);
        a.negativeMarkersPath = new PathVisualData(1, "NegativeMarkersPath", this.br);
        a.lowMarkersPath = new PathVisualData(1, "LowMarkersPath", this.bp);
        a.highMarkersPath = new PathVisualData(1, "HighMarkersPath", this.bn);
        a.firstMarkerPath = new PathVisualData(1, "FirstMarkerPath", this.bm);
        a.lastMarkerPath = new PathVisualData(1, "LastMarkerPath", this.bo);
    };
    XamSparklineView.prototype.preRender = function () {
    };
    XamSparklineView.prototype.isValid = function () {
        return true;
    };
    XamSparklineView.prototype.n = function (a) {
        return FontUtil.getFontForClass(this.ae, a);
    };
    XamSparklineView.prototype.ax = function (a, b, c, d, e) {
        a.setStyleProperty("width", b + "px");
        a.setStyleProperty("height", c + "px");
        a.setAttribute("width", d.toString());
        a.setAttribute("height", e.toString());
    };
    XamSparklineView.prototype.ap = function (a) {
        if (this.ad == null) {
            this.ad = function (b) {
                var c = a.bh;
                var d = a.a1;
                if (!isNaN_(c) && c != 0) {
                    return;
                }
                if (window.devicePixelRatio != undefined && window.devicePixelRatio != d) {
                    a.a1 = window.devicePixelRatio;
                }
            };
            window.addEventListener("resize", this.ad, false);
        }
        this.ad(null);
    };
    XamSparklineView.$t = markType(XamSparklineView, 'XamSparklineView', Base.$, [ISchedulableRender_$type]);
    return XamSparklineView;
}(Base));
export { XamSparklineView };
/**
 * @hidden
 */
var SparkFramePreparer = /** @class */ (function (_super) {
    tslib_1.__extends(SparkFramePreparer, _super);
    function SparkFramePreparer() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.b = null;
        _this.d = 0;
        _this.c = 0;
        return _this;
    }
    SparkFramePreparer.prototype.e = function (a) {
        var _this = this;
        var e_4, _a;
        this.b.r.al(false);
        a.g.clear();
        a.l.clear();
        a.j.clear();
        a.k.clear();
        a.i.clear();
        a.h.clear();
        var b = this.b.t;
        if (b == null) {
            return;
        }
        var c = b.count;
        var d = this.b.a3.top;
        var e = this.b.a3.left;
        var f = this.b.a3.width;
        var g = this.b.a3.height;
        var h = this.b.a3.bottom;
        var i = Math.floor((c + 1) / f);
        var j = truncate(Math.max(1, i));
        var k = 0;
        var l = truncate(Math.ceil(1 * c / j));
        var m = 0;
        var n = new List$1(Number_$type, 0);
        var o = this.b.q.an;
        var p = this.b.q.am;
        var q = this.b.q.bm;
        var r = o != 0 && q >= 1;
        var s = null;
        var t = null;
        if (p == 1 || p == 0) {
            this.d = 0;
        }
        else {
            if (l == 0) {
                this.d = 0;
            }
            else {
                this.d = f / l / 2;
            }
        }
        if (r) {
            var u = function (v) { return v + 1; };
            var v = function (w) { return b.item(w); };
            var w = function (x) { return _this.b.y(x); };
            var x = function (y) { return _this.b.z(y); };
            switch (this.b.q.an) {
                case 9:
                    s = TrendCalculators.e(b, q);
                    break;
                case 10:
                    s = TrendCalculators.b(b, q);
                    break;
                case 11:
                    s = TrendCalculators.c(b, q);
                    break;
                case 12:
                    s = TrendCalculators.a(b);
                    break;
                case 13:
                    s = TrendCalculators.g(b, q);
                    break;
                case 1:
                    t = LeastSquaresFit.k(c, u, v);
                    break;
                case 2:
                    t = LeastSquaresFit.o(c, u, v);
                    break;
                case 3:
                    t = LeastSquaresFit.i(c, u, v);
                    break;
                case 4:
                    t = LeastSquaresFit.p(c, u, v);
                    break;
                case 5:
                    t = LeastSquaresFit.q(c, u, v);
                    break;
                case 7:
                    t = LeastSquaresFit.j(c, u, v);
                    break;
                case 6:
                    t = LeastSquaresFit.l(c, u, v);
                    break;
                case 8:
                    t = LeastSquaresFit.n(c, u, v);
                    break;
            }
            if (s != null) {
                try {
                    for (var _b = tslib_1.__values(fromEnum(s)), _c = _b.next(); !_c.done; _c = _b.next()) {
                        var y = _c.value;
                        n.add(y);
                    }
                }
                catch (e_4_1) { e_4 = { error: e_4_1 }; }
                finally {
                    try {
                        if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
                    }
                    finally { if (e_4) throw e_4.error; }
                }
            }
            if (t != null) {
                var z = k * j;
                var aa = l * j;
                if (p == 1 || p == 0) {
                    aa = aa - 1;
                }
                var ab = 0 + this.d;
                var ac = f - this.d;
                var ad = 0;
                if (this.d != 0) {
                    ad = 0.5;
                }
                for (var ae = ab; ae <= ac; ae += 2) {
                    var af = ae / (f - 1);
                    var ag = z + af * (aa - z);
                    var ah = NaN;
                    switch (o) {
                        case 1:
                            ah = LeastSquaresFit.ad(t, ag - ad);
                            break;
                        case 2:
                            ah = LeastSquaresFit.ah(t, ag - ad);
                            break;
                        case 3:
                            ah = LeastSquaresFit.ab(t, ag - ad);
                            break;
                        case 4:
                            ah = LeastSquaresFit.ai(t, ag - ad);
                            break;
                        case 5:
                            ah = LeastSquaresFit.aj(t, ag - ad);
                            break;
                        case 7:
                            ah = LeastSquaresFit.ac(t, ag - ad);
                            break;
                        case 6:
                            ah = LeastSquaresFit.ae(t, ag - ad);
                            break;
                        case 8:
                            ah = LeastSquaresFit.ag(t, ag - ad);
                            break;
                    }
                    ag = w(ag);
                    ah = x(ah);
                    if (!isNaN_(ah) && !isInfinity(ah)) {
                        a.l.add({ $type: Point_$type, x: ag, y: ah });
                    }
                }
            }
        }
        var ai = this.b.t.minimum;
        var aj = this.b.t.maximum;
        var ak = this.b.q.a0;
        var al = this.b.q.az;
        this.c = h - (m - ak) / (al - ak) * g;
        if (this.c < 0) {
            this.c = 0;
        }
        else if (this.c > h) {
            this.c = h;
        }
        var am = this.c;
        var an;
        for (var ao = k; ao < l; ao++) {
            var ap = this.a(ao, j, c);
            var aq = ap[1];
            var ar = ap[2];
            this.f(ap, c, this.b.a3, ak, al);
            an = ap[1];
            if (ap[2] < am) {
                an = ap[2];
            }
            a.g.add(ap);
            if (!isNaN_(ap[0]) && !isNaN_(ap[1])) {
                a.j.add({ $type: Point_$type, x: ap[0], y: an });
            }
            if (r && s != null) {
                var as = ao * j;
                var at = h - (((n._inner[as] - ai) / (aj - ai)) * g);
                a.l.add({ $type: Point_$type, x: ap[0] + this.d, y: at });
            }
            if (aq < m) {
                a.k.add({ $type: Point_$type, x: ap[0], y: ap[1] });
            }
            if (ai == aq) {
                a.i.add({ $type: Point_$type, x: ap[0], y: ap[1] });
            }
            if (aj == ar) {
                a.h.add({ $type: Point_$type, x: ap[0], y: ap[2] });
            }
        }
        if (a.j.count == 0) {
            a.m = a.n = { $type: Point_$type, x: NaN, y: NaN };
        }
        else {
            a.m = a.j._inner[0];
            a.n = a.j._inner[a.j.count - 1];
        }
    };
    SparkFramePreparer.prototype.a = function (a, b, c) {
        var d = Math.min(a * b, c - 1);
        var e = Math.min(d + b - 1, c - 1);
        var f = true;
        var g = 0;
        var h = 0;
        for (var i = d; i <= e; ++i) {
            var j = this.b.t.item(i);
            if (f) {
                f = false;
                g = j;
                h = j;
            }
            else {
                g = Math.min(g, j);
                h = Math.max(h, j);
            }
        }
        var k = [0, 0, 0];
        k[0] = (0.5 * (d + e));
        k[1] = g;
        k[2] = h;
        return k;
    };
    SparkFramePreparer.prototype.f = function (a, b, c, d, e) {
        var f = c.left;
        var g = c.top;
        var h = c.width;
        var i = c.height;
        if (this.b.q.am == 1 || this.b.q.am == 0) {
            b--;
        }
        if (b < 0) {
            b = 0;
        }
        var j = b > 0 ? a[0] / b : b == 0 ? 0.5 : NaN;
        a[0] = f + j * h;
        if (this.b.q.am == 3) {
            if (a[1] > 0) {
                a[1] = g;
                a[2] = g;
            }
            else if (a[1] < 0) {
                a[1] = g + i;
                a[2] = g + i;
            }
            else {
                a[1] = g + (1 - ((a[1] - d) / (e - d))) * i;
                a[2] = g + (1 - ((a[2] - d) / (e - d))) * i;
            }
        }
        else {
            a[1] = g + (1 - ((a[1] - d) / (e - d))) * i;
            a[2] = g + (1 - ((a[2] - d) / (e - d))) * i;
        }
    };
    SparkFramePreparer.$t = markType(SparkFramePreparer, 'SparkFramePreparer');
    return SparkFramePreparer;
}(Base));
export { SparkFramePreparer };
/**
 * @hidden
 */
var SparklineConnector = /** @class */ (function (_super) {
    tslib_1.__extends(SparklineConnector, _super);
    function SparklineConnector(a, b) {
        var _this = _super.call(this) || this;
        _this.d = null;
        _this.b = null;
        _this.e = null;
        _this.a = null;
        _this.c = null;
        _this.e = b;
        if (a == null) {
            return _this;
        }
        _this.d = typeCast(XamSparkline.$, a);
        _this.a = _this.d.ag;
        _this.c = _this.d.ap;
        b.ap(_this.d);
        var c = new ServiceProvider_Spark();
        c.addService("ConfigurationMessages", new MessageChannel_Spark());
        c.addService("RenderingMessages", new MessageChannel_Spark());
        c.addService("InteractionMessages", new MessageChannel_Spark());
        c.addService("Model", _this.d);
        c.addService("View", _this.e);
        c.addService("HorizontalAxis", _this.a);
        c.addService("VerticalAxis", _this.c);
        _this.d.ak = c;
        _this.e.j = c;
        _this.a.h = c;
        _this.c.h = c;
        _this.b = new SparklineController(c);
        c.addService("Controller", _this.b);
        return _this;
    }
    SparklineConnector.$t = markType(SparklineConnector, 'SparklineConnector');
    return SparklineConnector;
}(Base));
export { SparklineConnector };
/**
 * @hidden
 */
var SparklineController = /** @class */ (function (_super) {
    tslib_1.__extends(SparklineController, _super);
    function SparklineController(a) {
        var _this = _super.call(this) || this;
        _this.k = null;
        _this.m = null;
        _this.l = null;
        _this.p = null;
        _this.r = null;
        _this.t = null;
        _this.s = null;
        _this.o = new SparkFramePreparer();
        _this.n = new SparkFrame();
        _this.a3 = Rect.empty;
        _this.aa = null;
        _this.k = a.getService("ConfigurationMessages");
        _this.m = a.getService("RenderingMessages");
        _this.l = a.getService("InteractionMessages");
        _this.aa = function (b, c) { return _this.ah(c.action, c.position, c.count, c.propertyName); };
        _this.q = a.getService("Model");
        _this.r = a.getService("View");
        _this.k.attachTarget(runOn(_this, _this.ag));
        _this.l.attachTarget(runOn(_this, _this.aj));
        return _this;
    }
    Object.defineProperty(SparklineController.prototype, "q", {
        get: function () {
            return this.p;
        },
        set: function (a) {
            var b = this.p != a;
            if (b) {
                this.p = a;
                this.an(runOn(this, this.aw));
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SparklineController.prototype, "x", {
        get: function () {
            return this.q != null ? this.q.itemsSource : null;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SparklineController.prototype, "u", {
        get: function () {
            return this.c(SparklineController.a2);
        },
        set: function (a) {
            this.h(SparklineController.a2, a);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SparklineController.prototype, "ad", {
        get: function () {
            return this.q != null ? this.q.c1 : null;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SparklineController.prototype, "ac", {
        get: function () {
            return this.q != null ? this.q.b6 : null;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SparklineController.prototype, "ab", {
        get: function () {
            return this.q != null ? this.q.toolTip : null;
        },
        enumerable: true,
        configurable: true
    });
    SparklineController.prototype.y = function (a) {
        var b = this.t.count;
        if (this.q.am == 1 || this.q.am == 0) {
            b--;
        }
        if (b < 0) {
            b = 0;
        }
        var c = b > 0 ? a / b : b == 0 ? 0.5 : NaN;
        c = this.a3.left + (c) * this.a3.width;
        return c;
    };
    SparklineController.prototype.z = function (a) {
        var b = ((a - this.q.a0) / (this.q.az - this.q.a0));
        b = (1 - b);
        b = this.a3.top + (b) * this.a3.height;
        return b;
    };
    SparklineController.prototype.w = function () {
        return !this.a3.isEmpty && this.a3.width > 0 && this.a3.height > 0 && this.q != null && this.q.a0 != this.q.az;
    };
    SparklineController.prototype.v = function (a) {
        if (a.oldValue != a.newValue) {
            return true;
        }
        return false;
    };
    SparklineController.prototype.av = function (a, b) {
        var _this = this;
        if (this.aa == null) {
            this.aa = function (c, d) { return _this.ah(d.action, d.position, d.count, d.propertyName); };
        }
        var c = typeCast(FastItemsSource.$, a);
        if (c != null) {
            c.event = delegateRemove(c.event, this.aa);
        }
        var d = typeCast(FastItemsSource.$, b);
        if (d != null) {
            d.event = delegateCombine(d.event, this.aa);
        }
    };
    SparklineController.prototype.ay = function () {
        if (this.q != null) {
            if (this.t == null) {
                this.q.a0 = this.q.az = NaN;
            }
            else {
                if (isNaN_(this.q.bd)) {
                    this.q.a0 = this.t.minimum;
                }
                else {
                    this.q.a0 = this.q.bd;
                }
                if (isNaN_(this.q.bc)) {
                    this.q.az = this.t.maximum;
                }
                else {
                    this.q.az = this.q.bc;
                }
                if (this.q.a0 == this.q.az) {
                    if (!isNaN_(this.q.bc) && isNaN_(this.q.bd)) {
                        this.q.a0 = this.q.az - 1;
                    }
                    else if (isNaN_(this.q.bc) && !isNaN_(this.q.bd)) {
                        this.q.az = this.q.a0 + 1;
                    }
                    else {
                        if (Math.floor(this.q.a0) < this.q.a0) {
                            this.q.a0 = Math.floor(this.q.a0);
                        }
                        else {
                            this.q.a0 = Math.floor(this.q.a0) - 1;
                        }
                        if (Math.ceil(this.q.az) > this.q.az) {
                            this.q.az = Math.ceil(this.q.az);
                        }
                        else {
                            this.q.az = Math.ceil(this.q.az) + 1;
                        }
                    }
                }
            }
        }
    };
    SparklineController.prototype.a0 = function () {
        if (this.u != null) {
            this.u.deregisterColumn(this.t);
            this.t = this.u.registerColumn(this.ad, null, false);
        }
        else {
            this.t = null;
        }
    };
    SparklineController.prototype.ax = function () {
        if (this.u != null) {
            this.u.deregisterColumn(this.s);
            this.s = this.u.registerColumnObject(this.ac, null, false);
            this.q.ar = this.s;
        }
        else {
            this.q.ar = this.s = null;
        }
    };
    SparklineController.prototype.au = function () {
        var a = new AxisRenderMessage_Spark();
        this.m.sendMessage(a);
    };
    SparklineController.prototype.an = function (a) {
        a();
    };
    SparklineController.prototype.aw = function () {
        this.u = this.getFastItemsSource(this.x);
        this.a0();
        this.ax();
        this.ay();
        this.au();
    };
    SparklineController.prototype.ah = function (a, b, c, d) {
        this.a0();
        this.ax();
        this.ay();
        this.au();
        this.an(runOn(this, this.ao));
    };
    SparklineController.prototype.az = function () {
        var a = new ToooltipTemplateMessage_Spark();
        a.template = this.ab;
        this.m.sendMessage(a);
    };
    SparklineController.prototype.ag = function (a) {
        if (typeCast(PropertyChangedMessage_Spark.$, a) !== null) {
            this.am(a);
        }
        else if (typeCast(ContainerSizeChangedMessage_Spark.$, a) !== null) {
            this.m.sendMessage(a);
        }
        else if (typeCast(DataChangedMessage_Spark.$, a) !== null) {
            this.ai(a);
        }
    };
    SparklineController.prototype.ai = function (a) {
        var b = this.u;
        if (b == null) {
            return;
        }
        switch (a.b) {
            case 2:
                b.handleCollectionChanged(new NotifyCollectionChangedEventArgs(2, 2, a.d, a.e, a.c));
                break;
            case 0:
                b.handleCollectionChanged(new NotifyCollectionChangedEventArgs(1, 0, a.d, a.c));
                break;
            case 1:
                b.handleCollectionChanged(new NotifyCollectionChangedEventArgs(1, 1, a.e, a.c));
                break;
            case 4:
                b.handleCollectionChanged(new NotifyCollectionChangedEventArgs(0, 4));
                break;
        }
        this.an(runOn(this, this.aw));
    };
    SparklineController.prototype.aj = function (a) {
        var b = a;
        if (typeCast(ViewportChangedMessage_Spark.$, b) !== null) {
            this.a1(b);
        }
        else if (typeCast(MouseLeaveMessage_Spark.$, b) !== null) {
            this.ak(b);
        }
        else if (typeCast(MouseMoveMessage_Spark.$, b) !== null) {
            this.al(b);
        }
        else if (typeCast(ContainerSizeChangedMessage_Spark.$, b) !== null) {
            this.m.sendMessage(a);
        }
    };
    SparklineController.prototype.am = function (a) {
        switch (a.propertyName) {
            case XamSparkline.$$p[13]:
                this.an(runOn(this, this.aw));
                break;
            case XamSparkline.$$p[41]:
                this.an(runOn(this, this.aw));
                break;
            case XamSparkline.$$p[14]:
                this.an(runOn(this, this.aw));
                break;
            case "ToolTip":
                this.az();
                break;
            case XamSparkline.$$p[26]:
            case XamSparkline.$$p[25]:
                this.ay();
                this.au();
                break;
            case XamSparkline.$$p[11]:
            case XamSparkline.$$p[43]:
                this.au();
                break;
            case XamSparkline.$$p[0]:
            case XamSparkline.$$p[27]:
            case XamSparkline.$$p[22]:
            case XamSparkline.$$p[3]:
            case XamSparkline.$$p[15]:
            case XamSparkline.$$p[7]:
            case XamSparkline.$$p[19]:
            case XamSparkline.$$p[28]:
            case XamSparkline.$$p[36]:
            case XamSparkline.$$p[31]:
                var b = new BrushChangedMessage_Spark();
                b.c = typeCast(Brush.$, a.newValue);
                b.b = a.propertyName;
                this.m.sendMessage(b);
                break;
            case XamSparkline.$$p[24]:
            case XamSparkline.$$p[5]:
            case XamSparkline.$$p[17]:
            case XamSparkline.$$p[9]:
            case XamSparkline.$$p[21]:
            case XamSparkline.$$p[30]:
            case XamSparkline.$$p[34]:
            case XamSparkline.$$p[35]:
                var c = new VisibilityMessage_Spark();
                c.c = EnumUtil.getEnumValue(Visibility_$type, a.newValue);
                c.b = a.propertyName;
                this.m.sendMessage(c);
                this.r.al(true);
                break;
            case XamSparkline.$$p[23]:
            case XamSparkline.$$p[4]:
            case XamSparkline.$$p[16]:
            case XamSparkline.$$p[8]:
            case XamSparkline.$$p[20]:
            case XamSparkline.$$p[29]:
                this.r.al(true);
                break;
            case XamSparkline.$$p[18]:
            case XamSparkline.$$p[38]:
                var d = new NumberChangedMessage_Spark();
                d.b = a.newValue;
                d.c = a.propertyName;
                this.m.sendMessage(d);
                break;
            case XamSparkline.$$p[10]:
            case XamSparkline.$$p[42]:
            case XamSparkline.$$p[12]:
            case XamSparkline.$$p[44]:
                this.at();
                break;
            case "Container":
                var e = new ContainerMessage_Spark();
                e.b = a.newValue;
                this.m.sendMessage(e);
                break;
            case "ActualPixelScalingRatio":
                {
                    var f = new PixelRatioMessage_Spark();
                    f.b = a.newValue;
                    this.m.sendMessage(f);
                }
                break;
        }
        if (this.v(a)) {
            this.an(runOn(this, this.ao));
        }
    };
    SparklineController.prototype.at = function () {
        var a = new ClearMessage_Spark();
        a.c = true;
        this.m.sendMessage(a);
    };
    SparklineController.prototype.a1 = function (a) {
        this.a3 = new Rect(0, a.newLeft, a.newTop, a.newWidth, a.newHeight);
        this.an(runOn(this, this.ao));
    };
    SparklineController.prototype.al = function (a) {
        var b = new ClearMessage_Spark();
        b.b = 4;
        this.m.sendMessage(b);
        var c = new TooltipMessage_Spark();
        c.b = 4;
        c.xOffset = a.position.x + 10;
        c.yOffset = a.position.y + 10;
        if (this.t != null && this.t.count > 0) {
            var d = new SparklineToolTipContext();
            d.high = this.t.maximum;
            d.low = this.t.minimum;
            d.first = this.t.item(0);
            d.last = this.t.item(this.t.count - 1);
            c.context = d;
        }
        this.m.sendMessage(c);
    };
    SparklineController.prototype.ak = function (a) {
        var b = new ClearMessage_Spark();
        b.b = 4;
        this.m.sendMessage(b);
    };
    SparklineController.prototype.af = function (a) {
        var b = new ClearMessage_Spark();
        b.b = a;
        this.m.sendMessage(b);
    };
    SparklineController.prototype.ae = function () {
        this.af(1);
        this.af(2);
        this.af(16);
        this.af(8);
    };
    SparklineController.prototype.ao = function () {
        this.ae();
        if (!this.w()) {
            return;
        }
        this.o.b = this;
        this.o.e(this.n);
        switch (this.q.am) {
            case 2:
                this.ap();
                break;
            case 3:
                this.as();
                break;
            case 0:
            case 1:
                this.ar();
                break;
        }
        var a = new NormalRangeMessage_Spark();
        a.k = this.a3.left;
        a.l = Math.max(this.a3.top, Math.min(this.a3.bottom, this.z(this.q.bf)));
        a.j = this.a3.width;
        var b = Math.max(this.a3.top, Math.min(this.a3.bottom, this.z(this.q.bg)));
        a.i = Math.abs(b - a.l);
        a.l = Math.min(a.l, b);
        a.d = this.q.as;
        this.m.sendMessage(a);
        var c = new TrendLineMessage_Spark();
        c.points = this.n.l.toArray();
        this.m.sendMessage(c);
    };
    SparklineController.prototype.ap = function () {
        var a = new ColumnMessage_Spark();
        a.d = this.n.j;
        a.g = this.n.k;
        a.f = this.n.i;
        a.e = this.n.h;
        a.k = this.n.m;
        a.l = this.n.n;
        a.j = this.n.g.count;
        a.h = this.o.c;
        a.i = this.o.d;
        a.c = this.q.am;
        this.m.sendMessage(a);
        this.aq();
    };
    SparklineController.prototype.as = function () {
        var a = new WinLossColumnMessage_Spark();
        a.d = this.n.j;
        a.g = this.n.k;
        a.f = this.n.i;
        a.e = this.n.h;
        a.k = this.n.m;
        a.l = this.n.n;
        a.j = this.n.g.count;
        a.h = this.o.c;
        a.i = this.o.d;
        a.c = this.q.am;
        this.m.sendMessage(a);
    };
    SparklineController.prototype.ar = function () {
        var e_5, _a, e_6, _b, e_7, _c;
        if (this.n.g.count == 0) {
            return;
        }
        var a = new List$1(List$1.$.specialize(Array_$type), 0);
        var b = new List$1(Array_$type, 0);
        var c = true;
        try {
            for (var _d = tslib_1.__values(fromEnum(this.n.g)), _e = _d.next(); !_e.done; _e = _d.next()) {
                var d = _e.value;
                if (isNaN_(d[1]) || isInfinity(d[1])) {
                    if (!c) {
                        a.add(b);
                    }
                    c = true;
                    continue;
                }
                if (c) {
                    b = new List$1(Array_$type, 0);
                    c = false;
                }
                b.add(d);
            }
        }
        catch (e_5_1) { e_5 = { error: e_5_1 }; }
        finally {
            try {
                if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
            }
            finally { if (e_5) throw e_5.error; }
        }
        if (!c) {
            a.add(b);
        }
        var e = new PolygonMessage_Spark();
        e.points = new List$1(Array_$type, 0);
        if (this.q.ao == 0) {
            var f = new List$1(Array_$type, 0);
            try {
                for (var _f = tslib_1.__values(fromEnum(a)), _g = _f.next(); !_g.done; _g = _f.next()) {
                    var g = _g.value;
                    f.o(g);
                }
            }
            catch (e_6_1) { e_6 = { error: e_6_1 }; }
            finally {
                try {
                    if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
                }
                finally { if (e_6) throw e_6.error; }
            }
            var h = this.j(f);
            e.points.add(h);
        }
        else {
            try {
                for (var _h = tslib_1.__values(fromEnum(a)), _j = _h.next(); !_j.done; _j = _h.next()) {
                    var i = _j.value;
                    var j = this.j(i);
                    e.points.add(j);
                }
            }
            catch (e_7_1) { e_7 = { error: e_7_1 }; }
            finally {
                try {
                    if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
                }
                finally { if (e_7) throw e_7.error; }
            }
        }
        this.m.sendMessage(e);
        this.aq();
    };
    SparklineController.prototype.j = function (a) {
        var e_8, _a, e_9, _b;
        var b = this.o.c;
        var c = new List$1(Point_$type, 0);
        var d;
        var e = this.q.am == 1;
        try {
            for (var _c = tslib_1.__values(fromEnum(a)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var f = _d.value;
                d = f[1];
                if (e) {
                    if (f[2] <= b) {
                        d = f[2];
                    }
                }
                c.add({ $type: Point_$type, x: f[0], y: d });
            }
        }
        catch (e_8_1) { e_8 = { error: e_8_1 }; }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
            }
            finally { if (e_8) throw e_8.error; }
        }
        if (this.q.am == 0) {
            var g = new List$1(Point_$type, 0);
            try {
                for (var _e = tslib_1.__values(fromEnum(a)), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var h = _f.value;
                    g.add({ $type: Point_$type, x: h[0], y: h[2] });
                }
            }
            catch (e_9_1) { e_9 = { error: e_9_1 }; }
            finally {
                try {
                    if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
                }
                finally { if (e_9) throw e_9.error; }
            }
            g.w();
            c.o(g);
        }
        if (this.q.am == 1 && c.count > 0) {
            var i = c._inner[0];
            var j = c._inner[c.count - 1];
            c.add({ $type: Point_$type, x: j.x, y: this.o.c });
            c.add({ $type: Point_$type, x: i.x, y: this.o.c });
        }
        return c.toArray();
    };
    SparklineController.prototype.aq = function () {
        var a = new MarkerMessage_Spark();
        a.e = this.n.j;
        a.f = this.n.k;
        a.d = this.n.i;
        a.c = this.n.h;
        a.m = this.n.m;
        a.n = this.n.n;
        a.k = this.q.a9;
        a.g = this.q.a2;
        a.i = this.q.a4;
        a.h = this.q.a3;
        a.j = this.q.a8;
        a.l = this.q.be;
        this.m.sendMessage(a);
    };
    SparklineController.prototype.getFastItemsSource = function (a) {
        var b = null;
        if (this.x != null) {
            var c = null;
            b = new FastItemsSource();
            b.e = this.x;
            c = new FastItemsSourceReference(b);
            c.b++;
            b = c.a;
        }
        return b;
    };
    SparklineController.prototype.releaseFastItemsSource = function (a) {
        if (a != null) {
            var b = null;
            --b.b;
        }
        return null;
    };
    SparklineController.$t = markType(SparklineController, 'SparklineController', DependencyObject.$, [IFastItemsSourceProvider_$type]);
    SparklineController.a2 = DependencyProperty.i("FastItemsSource", IFastItemsSource_$type, SparklineController.$, new PropertyMetadata(1, function (a, b) { return (typeCast(SparklineController.$, a)).av(b.oldValue, b.newValue); }));
    return SparklineController;
}(DependencyObject));
export { SparklineController };
/**
 * @hidden
 */
var XamSparkline = /** @class */ (function (_super) {
    tslib_1.__extends(XamSparkline, _super);
    function XamSparkline() {
        var _this = _super.call(this) || this;
        _this.al = null;
        _this.aj = null;
        _this.ah = new MessageChannel_Spark();
        _this.aw = NaN;
        _this.av = NaN;
        _this.ar = null;
        _this.ag = null;
        _this.ap = null;
        _this.ay = NaN;
        _this.ax = 1;
        _this.ab = XamSparkline.$;
        _this.ap = new VerticalAxisView(_this);
        _this.ag = new HorizontalAxisView(_this);
        _this.al = new SparklineConnector(_this, new XamSparklineView());
        return _this;
    }
    Object.defineProperty(XamSparkline.prototype, "toolTip", {
        get: function () {
            return this.c(XamSparkline.eg);
        },
        set: function (a) {
            this.h(XamSparkline.eg, a);
            this.fb = a == null || a.toString().length == 0 ? 1 : 0;
        },
        enumerable: true,
        configurable: true
    });
    XamSparkline.prototype.at = function () {
        return this.bl != null;
    };
    XamSparkline.prototype.ct = function (a) {
        return this.bl(a);
    };
    Object.defineProperty(XamSparkline.prototype, "ak", {
        get: function () {
            return this.aj;
        },
        set: function (a) {
            var b = this.aj;
            this.aj = a;
            this.de(b, this.aj);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(XamSparkline.prototype, "ai", {
        get: function () {
            return this.ah;
        },
        set: function (a) {
            this.ah = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(XamSparkline.prototype, "a0", {
        get: function () {
            return this.aw;
        },
        set: function (a) {
            this.aw = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(XamSparkline.prototype, "az", {
        get: function () {
            return this.av;
        },
        set: function (a) {
            this.av = a;
        },
        enumerable: true,
        configurable: true
    });
    XamSparkline.prototype.de = function (a, b) {
        if (a != null) {
            this.ai.detachFromNext();
        }
        if (b != null) {
            this.ai.connectTo(b.getService("ConfigurationMessages"));
        }
    };
    XamSparkline.prototype.dd = function (a, b, c) {
        if (a == "PixelScalingRatio") {
            if (!isNaN_(DeviceUtils.a(this.bh))) {
                this.a1 = DeviceUtils.a(this.bh);
            }
        }
        this.ai.sendMessage(((function () {
            var $ret = new PropertyChangedMessage_Spark();
            $ret.propertyName = a;
            $ret.oldValue = b;
            $ret.newValue = c;
            return $ret;
        })()));
    };
    XamSparkline.prototype.destroy = function () {
        this.ai.sendMessage(((function () {
            var $ret = new PropertyChangedMessage_Spark();
            $ret.propertyName = "Container";
            $ret.newValue = null;
            return $ret;
        })()));
    };
    XamSparkline.prototype.provideContainer = function (a) {
        this.ai.sendMessage(((function () {
            var $ret = new PropertyChangedMessage_Spark();
            $ret.propertyName = "Container";
            $ret.newValue = a;
            return $ret;
        })()));
    };
    XamSparkline.prototype.notifyResized = function () {
        this.ai.sendMessage(new ContainerSizeChangedMessage_Spark());
    };
    XamSparkline.prototype.dc = function (source_, a, b, c) {
        if (source_.dataView && source_.dataSource) {
            source_ = source_.dataView();
        }
        ;
        if (source_ != this.itemsSource) {
            return;
        }
        this.ai.sendMessage(((function () {
            var $ret = new DataChangedMessage_Spark();
            $ret.b = 2;
            $ret.e = b;
            $ret.d = c;
            $ret.c = a;
            return $ret;
        })()));
    };
    XamSparkline.prototype.c8 = function (source_) {
        if (source_.dataView && source_.dataSource) {
            source_ = source_.dataView();
        }
        ;
        if (source_ != this.itemsSource) {
            return;
        }
        this.ai.sendMessage(((function () {
            var $ret = new DataChangedMessage_Spark();
            $ret.b = 4;
            return $ret;
        })()));
    };
    XamSparkline.prototype.c9 = function (source_, a, b) {
        if (source_.dataView && source_.dataSource) {
            source_ = source_.dataView();
        }
        ;
        if (source_ != this.itemsSource) {
            return;
        }
        this.ai.sendMessage(((function () {
            var $ret = new DataChangedMessage_Spark();
            $ret.b = 0;
            $ret.d = b;
            $ret.c = a;
            return $ret;
        })()));
    };
    XamSparkline.prototype.da = function (source_, a, b) {
        if (source_.dataView && source_.dataSource) {
            source_ = source_.dataView();
        }
        ;
        if (source_ != this.itemsSource) {
            return;
        }
        this.ai.sendMessage(((function () {
            var $ret = new DataChangedMessage_Spark();
            $ret.b = 1;
            $ret.e = b;
            $ret.c = a;
            return $ret;
        })()));
    };
    XamSparkline.prototype.aq = function () {
        var a = new SparklineVisualData();
        a.name = "SparklineVisualData";
        a.horizontalAxis = this.ag.i();
        a.verticalAxis = this.ap.i();
        this.al.e.an(a);
        return a;
    };
    Object.defineProperty(XamSparkline.prototype, "bh", {
        get: function () {
            return this.ay;
        },
        set: function (a) {
            var b = this.ay;
            this.ay = a;
            this.dd("PixelScalingRatio", b, this.ay);
            if (this.ay != b) {
                this.dd("PixelScalingRatio", b, this.ay);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(XamSparkline.prototype, "a1", {
        get: function () {
            return this.ax;
        },
        set: function (a) {
            var b = this.ax;
            this.ax = a;
            if (this.ax != b) {
                this.dd("ActualPixelScalingRatio", b, this.ax);
            }
        },
        enumerable: true,
        configurable: true
    });
    XamSparkline.$t = markType(XamSparkline, 'XamSparkline', Control.$);
    XamSparkline.bb = -1;
    XamSparkline.a7 = -1;
    XamSparkline.eg = DependencyProperty.i("ToolTip", Base.$, XamSparkline.$, new PropertyMetadata(2, null, function (a, b) { return (typeCast(XamSparkline.$, a)).dd("ToolTip", b.oldValue, b.newValue); }));
    XamSparkline.bk = -1;
    return XamSparkline;
}(Control));
export { XamSparkline };
Type.dep(DependencyProperty, PropertyMetadata, XamSparkline, 'dd', ['Brush:er:dg', [Brush.$, null], 'DisplayNormalRangeInFront:as:dh', [0, true], 'DisplayType:am:di', [SparklineDisplayType_$type, enumGetBox(SparklineDisplayType_$type, 0)], 'FirstMarkerBrush:es:dj', [Brush.$, null], 'FirstMarkerSize:a2:dk', [1, XamSparkline.bb], 'FirstMarkerVisibility:e3:dl', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'FormatLabel:bl:dm', [Delegate_$type], 'HighMarkerBrush:et:dn', [Brush.$, null], 'HighMarkerSize:a3:dp', [1, XamSparkline.bb], 'HighMarkerVisibility:e4:dq', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'HorizontalAxisBrush:eu:dr', [Brush.$, null], 'HorizontalAxisLabel:bn:ds', [4, "{0}"], 'HorizontalAxisVisibility:e5:dt', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'ItemsSource::du', [IEnumerable_$type, null], 'LabelMemberPath:b6:dv', [2, null], 'LastMarkerBrush:ev:dw', [Brush.$, null], 'LastMarkerSize:a4:dx', [1, XamSparkline.bb], 'LastMarkerVisibility:e6:dy', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'LineThickness:a5:dz', [1, XamSparkline.a7], 'LowMarkerBrush:ew:d0', [Brush.$, null], 'LowMarkerSize:a8:d1', [1, XamSparkline.bb], 'LowMarkerVisibility:e7:d2', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'MarkerBrush:ex:d3', [Brush.$, null], 'MarkerSize:a9:d4', [1, XamSparkline.bb], 'MarkerVisibility:e8:d5', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'Maximum:bc:d6', [1, NaN], 'Minimum:bd:d7', [1, NaN], 'NegativeBrush:ey:d8', [Brush.$, null], 'NegativeMarkerBrush:ez:d9', [Brush.$, null], 'NegativeMarkerSize:be:ea', [1, XamSparkline.bb], 'NegativeMarkerVisibility:e9:eb', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'NormalRangeFill:e0:ec', [Brush.$, null], 'NormalRangeMaximum:bf:ed', [1, 0], 'NormalRangeMinimum:bg:ee', [1, 0], 'NormalRangeVisibility:fa:ef', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'ToolTipVisibility:fb:eh', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'TrendLineBrush:e1:ei', [Brush.$, null], 'TrendLinePeriod:bm:ej', [1, 7], 'TrendLineThickness:bi:ek', [1, XamSparkline.bk], 'TrendLineType:an:el', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'UnknownValuePlotting:ao:em', [UnknownValuePlotting_$type, enumGetBox(UnknownValuePlotting_$type, 1)], 'ValueMemberPath:c1:en', [2, null], 'VerticalAxisBrush:e2:eo', [Brush.$, null], 'VerticalAxisLabel:bp:ep', [4, "{0:n}"], 'VerticalAxisVisibility:fc:eq', [Visibility_$type, enumGetBox(Visibility_$type, 1)]]);
