UNPKG

igniteui-angular-gauges

Version:

Ignite UI Angular gauge components.

2,176 lines 78.5 kB
/*
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 { Control } from "igniteui-angular-core";
import { INotifyPropertyChanged_$type, Base, PropertyChangedEventArgs, runOn, delegateCombine, enumGetBox, Number_$type, String_$type, Array_$type, Point_$type, delegateRemove, fromEn, markType, markDep, typeCast, fromEnum, TypeRegistrar } from "igniteui-angular-core";
import { DoubleAnimator } from "igniteui-angular-core";
import { BulletGraphFrame } from "./BulletGraphFrame";
import { LinearGraphScaler } from "./LinearGraphScaler";
import { LinearScaleOrientation_$type } from "./LinearScaleOrientation";
import { DependencyProperty } from "igniteui-angular-core";
import { Brush } from "igniteui-angular-core";
import { LinearGraphRangeCollection } from "./LinearGraphRangeCollection";
import { BrushCollection } from "igniteui-angular-core";
import { HighlightedValueDisplayMode_$type } from "igniteui-angular-core";
import { BindingFormatter } from "igniteui-angular-core";
import { StackPool$1 } from "igniteui-angular-core";
import { Path } from "igniteui-angular-core";
import { TextBlock } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { XamLinearGraphRange } from "./XamLinearGraphRange";
import { FormatLinearGraphLabelEventArgs } from "./FormatLinearGraphLabelEventArgs";
import { AlignLinearGraphLabelEventArgs } from "./AlignLinearGraphLabelEventArgs";
import { BulletGraphVisualData } from "./BulletGraphVisualData";
import { ToolTipInfo } from "./ToolTipInfo";
import { RectData } from "igniteui-angular-core";
import { LinearGraphScaleLabelVisualDataList } from "./LinearGraphScaleLabelVisualDataList";
import { LinearGraphScaleTickmarkVisualDataList } from "./LinearGraphScaleTickmarkVisualDataList";
import { LinearGraphRangeVisualDataList } from "./LinearGraphRangeVisualDataList";
import { ValueVisualData } from "./ValueVisualData";
import { BulletGraphTargetValueVisualData } from "./BulletGraphTargetValueVisualData";
import { LinearGraphRangeVisualData } from "./LinearGraphRangeVisualData";
import { LinearGraphToolTipVisualData } from "./LinearGraphToolTipVisualData";
import { LinearGraphTooltipDataContext } from "./LinearGraphTooltipDataContext";
import { AppearanceHelper } from "igniteui-angular-core";
import { PointData } from "igniteui-angular-core";
import { PathVisualData } from "igniteui-angular-core";
import { GetPointsSettings } from "igniteui-angular-core";
import { PolygonUtil } from "igniteui-angular-core";
import { LinearGraphRectFrame } from "./LinearGraphRectFrame";
import { Size } from "igniteui-angular-core";
import { Tuple$2 } from "igniteui-angular-core";
import { BrushUtil } from "igniteui-angular-core";
import { PathGeometry } from "igniteui-angular-core";
import { PathFigure } from "igniteui-angular-core";
import { LineSegment } from "igniteui-angular-core";
import { DeviceUtils } from "igniteui-angular-core";
import { FontUtil } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_, isInfinity, intDivide, truncate } from "igniteui-angular-core";
import { EventProxy } from "igniteui-angular-core";
import { RenderingContext } from "igniteui-angular-core";
import { Dictionary$2 } from "igniteui-angular-core";
import { CanvasScalingHelpers } from "igniteui-angular-core";
import { CanvasViewRenderer } from "igniteui-angular-core";
import { CanvasGestureDOMEventProxy } from "igniteui-angular-core";
import { LinearGraphScaleLabelVisualData } from "./LinearGraphScaleLabelVisualData";
import { LinearGraphScaleTickmarkVisualData } from "./LinearGraphScaleTickmarkVisualData";
import { SizeData } from "igniteui-angular-core";
import { arrayCopy1 } from "igniteui-angular-core";
import { stringIsNullOrEmpty } from "igniteui-angular-core";
/**
 * @hidden
 */
export let XamBulletGraph = /*@__PURE__*/ (() => {
    class XamBulletGraph extends Control {
        constructor() {
            super();
            this.propertyChanged = null;
            this.aw = null;
            this.bq = 0;
            this.formatLabel = null;
            this.alignLabel = null;
            this.an = null;
            this.am = null;
            this.al = null;
            this.ar = null;
            this.av = null;
            this.bn = 0;
            this.bm = 100;
            this.a1 = 0;
            this.bl = 0.5;
            this.ay = 1;
            this.aj = null;
            this.be = false;
            this.a5 = null;
            this.a3 = null;
            this.a2 = null;
            this.a6 = null;
            this.a4 = null;
            this._view = null;
            this.ig = null;
            this.ie = null;
            this.id = null;
            this.bp = NaN;
            this.bo = 1;
            this.bg = new List$1(TextBlock.$, 0);
            this.bj = new List$1(TextBlock.$, 0);
            this.bi = new List$1(Path.$, 0);
            this.bh = new List$1(Path.$, 0);
            this.a8 = false;
            this.bp = NaN;
            this.bo = 1;
            this.av = new XamLinearGraphRange();
            let a = this.av;
            a.propertyChanged = delegateCombine(a.propertyChanged, runOn(this, this.fv));
            this.view = new XamBulletGraphView(this);
            this.view.a9();
            this.ig = Rect.empty;
            this.ie = Rect.empty;
            this.id = Rect.empty;
            this.an = new BulletGraphFrame();
            this.am = new BulletGraphFrame();
            this.al = new BulletGraphFrame();
            this.ranges = new LinearGraphRangeCollection();
            this.a8 = true;
            this.aw = new DoubleAnimator(0, 1, this.c8);
            let b = this.aw;
            b.propertyChanged = delegateCombine(b.propertyChanged, runOn(this, this.fa));
            this.ab = XamBulletGraph.$;
            this.a4 = ((() => {
                let $ret = new StackPool$1(Path.$);
                $ret.b = runOn(this.view, this.view.bj);
                $ret.c = runOn(this.view, this.view.bk);
                $ret.d = runOn(this.view, this.view.bl);
                $ret.j = runOn(this.view, this.view.cs);
                return $ret;
            })());
            this.a5 = ((() => {
                let $ret = new StackPool$1(Path.$);
                $ret.b = runOn(this.view, this.view.bc);
                $ret.c = runOn(this.view, this.view.bd);
                $ret.d = runOn(this.view, this.view.be);
                $ret.j = runOn(this.view, this.view.cr);
                return $ret;
            })());
            this.a3 = ((() => {
                let $ret = new StackPool$1(Path.$);
                $ret.b = runOn(this.view, this.view.bc);
                $ret.c = runOn(this.view, this.view.bd);
                $ret.d = runOn(this.view, this.view.be);
                $ret.j = runOn(this.view, this.view.cr);
                return $ret;
            })());
            this.a2 = ((() => {
                let $ret = new StackPool$1(TextBlock.$);
                $ret.b = runOn(this.view, this.view.a1);
                $ret.c = runOn(this.view, this.view.a2);
                $ret.d = runOn(this.view, this.view.a3);
                $ret.j = runOn(this.view, this.view.b0);
                return $ret;
            })());
            this.a6 = ((() => {
                let $ret = new StackPool$1(TextBlock.$);
                $ret.b = runOn(this.view, this.view.bt);
                $ret.c = runOn(this.view, this.view.bu);
                $ret.d = runOn(this.view, this.view.bv);
                $ret.j = runOn(this.view, this.view.b1);
                return $ret;
            })());
        }
        fm(a) {
            this.ft(a);
        }
        ft(a) {
            let b = this.propertyChanged;
            if (b != null) {
                b(this, new PropertyChangedEventArgs(a));
            }
        }
        onDetachedFromUI() {
            this.view.a8();
        }
        onAttachedToUI() {
            this.view.a4();
        }
        fa(a, b) {
            this.c0 = this.aw.o;
        }
        get a7() {
            return this.aw.f();
        }
        get c0() {
            return this.bq;
        }
        set c0(a) {
            let b = this.bq;
            this.bq = a;
            this.fl("TransitionProgress", b, this.bq);
        }
        f6() {
            this.bq = 0;
            this.aw.w();
            this.aw.v();
        }
        get bd() {
            return this.c8 > 0;
        }
        get h5() {
            return this.c(XamBulletGraph.g7);
        }
        set h5(a) {
            this.h(XamBulletGraph.g7, a);
        }
        get h6() {
            return this.c(XamBulletGraph.g8);
        }
        set h6(a) {
            this.h(XamBulletGraph.g8, a);
        }
        get ci() {
            return this.c(XamBulletGraph.g9);
        }
        set ci(a) {
            this.h(XamBulletGraph.g9, a);
        }
        get bt() {
            return this.bn;
        }
        set bt(a) {
            this.bn = a;
        }
        get bs() {
            return this.bm;
        }
        set bs(a) {
            this.bm = a;
        }
        get br() {
            return this.bl;
        }
        set br(a) {
            let b = this.bl;
            this.bl = a;
            if (b != this.bl) {
                this.fl("ActualHighlightValueOpacity", b, a);
            }
        }
        f9() {
            this.br = isNaN_(this.b1) ? 0.5 : Math.max(0, Math.min(this.b1, 1));
        }
        get az() {
            return this.ay;
        }
        set az(a) {
            this.ay = a;
        }
        f8() {
            if (this.a0 != 1) {
                if (isNaN_(this.b0) || isInfinity(this.b0)) {
                    this.az = 1;
                }
                else {
                    this.az = 2;
                }
            }
            else {
                this.az = 1;
            }
        }
        ff() {
            this.a1 = 0;
            this.view.cm().an = null;
        }
        bz(a) {
            let b = 0;
            let c = a.x;
            if (this.as == 1) {
                b = a.y;
                c = this.ij.height;
            }
            return this.ar.k(c - b);
        }
        at() {
            let a = new BulletGraphVisualData();
            a.viewport = new RectData(this.ij.left, this.ij.top, this.ij.width, this.ij.height);
            a.scaleLabels = new LinearGraphScaleLabelVisualDataList();
            a.scaleTickmarks = new LinearGraphScaleTickmarkVisualDataList();
            a.ranges = new LinearGraphRangeVisualDataList();
            a.value = ((() => {
                let $ret = new ValueVisualData();
                $ret.value = this.c1;
                return $ret;
            })());
            a.highlightValue = ((() => {
                let $ret = new ValueVisualData();
                $ret.value = this.b0;
                return $ret;
            })());
            a.targetValue = ((() => {
                let $ret = new BulletGraphTargetValueVisualData();
                $ret.value = this.co;
                return $ret;
            })());
            this.view.aw(a);
            let b = this.view.l();
            if (b != null) {
                let c;
                switch (b.c) {
                    case "range":
                        c = a.ranges._inner[b.b];
                        break;
                    case "value":
                        c = a.value;
                        break;
                    default:
                        c = a.targetValue;
                        break;
                }
                a.toolTip = ((() => {
                    let $ret = new LinearGraphToolTipVisualData();
                    $ret.item = c;
                    $ret.itemBrush = AppearanceHelper.b(b.a.brush);
                    $ret.outline = AppearanceHelper.b(b.a.outline);
                    $ret.thickness = b.a.thickness;
                    return $ret;
                })());
            }
            return a;
        }
        dh() {
            let a = this.at();
            a.scaleByViewport();
            return a.serialize();
        }
        destroy() {
            this.provideContainer(null);
        }
        provideContainer(a) {
            this.view.a6(a);
        }
        onMouseOver(a, b, c) {
            if (this.be) {
                this.f5(a, null);
            }
        }
        onMouseLeave() {
            if (this.be) {
                this.f5({ $type: Point_$type, x: -10000, y: -10000 }, null);
            }
        }
        containerResized() {
            this.view.a7();
        }
        f7() {
            this.view.bs();
        }
        fe() {
            this.view.flush();
        }
        bk(a) {
            let b = new List$1(Point_$type, 0);
            for (let c = 0; c < a.count; c++) {
                b.add({ $type: Point_$type, x: a._inner[c].x, y: a._inner[c].y });
            }
            return b;
        }
        f5(a, b) {
            let c = new PathVisualData(1, "targetValue", this.view.cp());
            let d = c.getPoints(new GetPointsSettings());
            if (d.count > 0) {
                let e = PolygonUtil.b(this.bk(d._inner[0]), a);
                if (e == true) {
                    this.view.br(a, b, -1, "targetvalue");
                    return;
                }
            }
            let f = new PathVisualData(1, "value", this.view.cq());
            let g = f.getPoints(new GetPointsSettings());
            if (g.count > 0) {
                let h = PolygonUtil.b(this.bk(g._inner[0]), a);
                if (h == true) {
                    this.view.br(a, b, -1, "value");
                    return;
                }
            }
            for (let i = 0; i < this.bh.count; i++) {
                let j = new PathVisualData(1, "range", this.bh._inner[i]);
                let k = j.getPoints(new GetPointsSettings());
                if (k.count > 0) {
                    let l = PolygonUtil.b(this.bk(k._inner[0]), a);
                    if (l == true) {
                        this.view.br(a, b, i, "range");
                        return;
                    }
                }
            }
            this.view.az();
        }
        fy() {
            if (!this.a8) {
                return;
            }
            let a = this.am.c;
            if (this.as == 0) {
                let b = 0;
                for (let c = 0; c < a.c.length; c++) {
                    b = Math.max(b, a.c[c]);
                }
                let d = this.ij.height >= b ? this.ij.height - b : this.ij.height;
                this.ii = new Rect(0, 0, 0, this.ij.width, d);
            }
            else {
                let e = 0;
                for (let f = 0; f < a.f.length; f++) {
                    e = Math.max(e, a.f[f]);
                }
                let g = this.ij.width >= e ? this.ij.width - e : this.ij.width;
                this.ii = new Rect(0, e, 0, g, this.ij.height);
            }
        }
        get view() {
            return this._view;
        }
        set view(a) {
            this._view = a;
        }
        get ij() {
            return this.ig;
        }
        set ij(a) {
            let b = this.ig;
            this.ig = a;
            if (!b.equals1(this.ig)) {
                this.fn(b, this.ig);
            }
        }
        get ii() {
            return this.ie;
        }
        set ii(a) {
            this.ie = a;
        }
        get ih() {
            return this.id;
        }
        set ih(a) {
            this.id = a;
        }
        get cf() {
            return this.bp;
        }
        set cf(a) {
            let b = this.bp;
            this.bp = a;
            this.fl("PixelScalingRatio", b, this.bp);
        }
        get bu() {
            return this.bo;
        }
        set bu(a) {
            let b = this.bo;
            this.bo = a;
            this.fl("ActualPixelScalingRatio", b, this.bo);
        }
        ba() {
            return !isNaN_(this.bt) && !isNaN_(this.bs) && !this.ij.isEmpty && this.view.s();
        }
        fb() {
            if (!this.ba()) {
                return;
            }
            let a = this.cm();
            this.ar = new LinearGraphScaler(this.bt, this.bs, a, a + this.cl(), this.a9);
            if (this.a8) {
                if (this.a7) {
                    if (this.aw.g) {
                        this.aw.t();
                    }
                    let b = this.an;
                    this.an = this.al;
                    this.al = b;
                }
                else {
                    let c = this.an;
                    this.an = this.am;
                    this.am = c;
                }
            }
            else if (this.a7) {
                this.al.d(this.c0, this.an, this.am);
                this.fz(this.al);
                this.f1(this.al);
                this.f2(this.al);
                this.f4(this.al);
            }
            if (this.a8) {
                this.fp();
                this.fy();
                if (this.a1 == 1) {
                    this.a1 = 2;
                    let d = this.an.c;
                    d.af = this.aq(this.c1, true, false);
                }
                else if (this.a1 == 4) {
                    if (this.c8 > 0) {
                        this.a1 = 5;
                        let e = this.am.c;
                        e.af = this.aq(this.c1, true, false);
                    }
                    else {
                        this.ff();
                    }
                }
                this.fr();
                this.fs();
                this.fq();
                this.fo();
            }
            if (this.a8 && this.bd) {
                this.f6();
                this.al.d(this.c0, this.an, this.am);
                this.fz(this.al);
                this.f1(this.al);
                this.f2(this.al);
                this.f4(this.al);
                this.f3(this.al);
                this.f0(this.al);
            }
            else {
                if (this.a8) {
                    this.fz(this.am);
                    this.f1(this.am);
                    this.f2(this.am);
                    this.f4(this.am);
                    this.f3(this.am);
                    this.f0(this.am);
                }
            }
            this.a8 = false;
            this.view.as();
        }
        fq() {
            let a = this.am;
            let b = a.c;
            let c = this.ar;
            let d = this.b9;
            let e = this.ii;
            if (isNaN_(d)) {
                d = 3;
            }
            b.u = this.cn;
            b.r = this.ck;
            b.s = 0;
            b.t = 1;
            b.m.clear();
            for (let f = 0; f < this.ranges.count; f++) {
                let g = this.ranges._inner[f];
                if (g.j <= this.bt || g.o > this.bs) {
                    continue;
                }
                let h = g.o;
                let i = g.j;
                if (h < this.bt) {
                    h = this.bt;
                }
                if (i > this.bs) {
                    i = this.bs;
                }
                let j = new LinearGraphRectFrame();
                j.i = g.an != null ? g.an : this.h3(f, this.ah);
                j.j = g.ao != null ? g.ao : this.h3(f, this.ai);
                j.h = g.p;
                j.g = c.i(h);
                j.d = c.i(i);
                j.e = g.l;
                j.b = g.k;
                j.f = g.n;
                j.c = g.m;
                if (isNaN_(j.e)) {
                    j.e = this.cg;
                }
                j.b = g.k;
                if (isNaN_(j.b)) {
                    j.b = this.cg;
                }
                j.f = g.n;
                if (isNaN_(j.f)) {
                    j.f = this.ch;
                }
                j.c = g.m;
                if (isNaN_(j.c)) {
                    j.c = this.ch;
                }
                b.m.add(j);
            }
            b.l.i = this.h5;
            b.l.j = this.h6;
            b.l.h = this.ci;
            b.l.g = c.i(this.bt);
            b.l.d = c.i(this.bs);
            b.l.e = this.cg;
            b.l.b = this.cg;
            b.l.f = this.ch;
            b.l.c = this.ch;
            b.ab = this.h2;
            b.ad = this.h9;
            b.x = this.cz;
            b.w = this.cx;
            b.v = this.ct;
            b.ac = this.h4;
            b.q = this.ce;
            b.p = this.cc;
            b.o = this.ca;
            let k = this.b2;
            if (isNaN_(k)) {
                k = (this.bs - this.bt) / 10;
            }
            if (k == 0) {
                k = this.bs - this.bt;
            }
            let l = new List$1(Number_$type, 0);
            let m = new List$1(Number_$type, 0);
            if (k > 0) {
                let n = this.bt + this.cv;
                let o = this.bs - this.cw;
                let p = 100000;
                let q = Math.abs(o - n) / p;
                if (k >= q) {
                    for (let r = n; r <= o || this.bf(r, o, k); r = r + k) {
                        l.add(c.i(r));
                        for (let s = 0; s < d; s++) {
                            let t = (k / (d + 1)) * (s + 1);
                            if (t + r > o) {
                                continue;
                            }
                            m.add(c.i(t + r));
                        }
                    }
                }
            }
            if (b.j.length != l.count || b.i.length != m.count) {
                b.j = new Array(l.count);
                b.i = new Array(m.count);
            }
            for (let u = 0; u < l.count; u++) {
                b.j[u] = l._inner[u];
            }
            for (let v = 0; v < m.count; v++) {
                b.i[v] = m._inner[v];
            }
        }
        ik() {
            if (!this.bb) {
                return new Size(1, 0, 0);
            }
            let a = this.b2;
            let b = this.b4;
            if (isNaN_(a)) {
                a = (this.bs - this.bt) / 10;
            }
            if (isNaN_(b)) {
                b = a;
            }
            if (b == 0) {
                b = this.bs - this.bt;
            }
            let c = new List$1(Number_$type, 0);
            if (b > 0) {
                let d = this.b5 + this.bt;
                let e = this.bs - this.b6;
                let f = 100000;
                let g = Math.abs(e - d) / f;
                if (b >= g) {
                    for (let h = d; h <= e || this.bf(h, e, a); h += b) {
                        c.add(h);
                    }
                }
            }
            let i = new Array(c.count);
            let j = new Array(c.count);
            for (let k = 0; k < c.count; k++) {
                let l = c._inner[k];
                if (this.formatLabel == null && this.aj == null) {
                    l = (Math.round(l * 100) / 100);
                }
                let m = l.toString();
                if (this.aj != null) {
                    m = this.aj.i(l);
                }
                let n = new FormatLinearGraphLabelEventArgs();
                n.value = l;
                n.label = m;
                if (this.formatLabel != null) {
                    this.formatLabel(this, n);
                }
                m = n.label;
                let o = this.view.ct(((() => {
                    let $ret = new TextBlock();
                    $ret.al = m;
                    return $ret;
                })()));
                i[k] = o.width;
                j[k] = o.height;
            }
            let p = 0;
            let q = 0;
            let r = 1 - this.ck + this.cn;
            if (this.as == 0) {
                for (let s = 0; s < j.length; s++) {
                    q = Math.max(q, j[s]);
                }
                for (let t = 0; t < i.length; t++) {
                    p += i[t];
                }
                if (i.length > 0) {
                    p += i[0] / 2;
                }
                if (i.length > 1) {
                    p += i[i.length - 1] / 2;
                }
                if (i.length > 0) {
                    p += (i.length - 1) * 5;
                }
                if (r > 0) {
                    p = p / Math.abs(1 - r);
                }
            }
            else {
                for (let u = 0; u < i.length; u++) {
                    p = Math.max(p, i[u]);
                }
                for (let v = 0; v < j.length; v++) {
                    q += j[v];
                }
                if (j.length > 0) {
                    q -= j[0] / 2;
                }
                if (j.length > 1) {
                    q -= j[j.length - 1] / 2;
                }
                if (r > 0) {
                    q = q / Math.abs(1 - r);
                }
                if (j.length > 0) {
                    q += (j.length - 1) * 5;
                }
            }
            return new Size(1, p, q);
        }
        fp() {
            let a = this.am;
            let b = a.c;
            let c = this.ar;
            let d = this.b2;
            let e = this.b4;
            let f = this.b9;
            if (isNaN_(d)) {
                d = (this.bs - this.bt) / 10;
            }
            if (isNaN_(e)) {
                e = d;
            }
            if (e == 0) {
                e = this.bs - this.bt;
            }
            let g = new List$1(Tuple$2.$.specialize(Number_$type, Number_$type), 0);
            if (e > 0) {
                let h = this.b5 + this.bt;
                let i = this.bs - this.b6;
                let j = 100000;
                let k = Math.abs(i - h) / j;
                if (e >= k) {
                    for (let l = h; l <= i || this.bf(l, i, e); l = l + e) {
                        g.add(new Tuple$2(Number_$type, Number_$type, l, c.i(l)));
                    }
                }
            }
            if (b.d.length != g.count) {
                b.e = new Array(g.count);
                b.d = new Array(g.count);
                b.f = new Array(g.count);
                b.c = new Array(g.count);
                b.g = new Array(g.count);
                b.h = new Array(g.count);
            }
            b.n = this.b3;
            let m = new FormatLinearGraphLabelEventArgs();
            m.actualMinimumValue = this.bt;
            m.actualMaximumValue = this.bs;
            let n = new AlignLinearGraphLabelEventArgs();
            n.actualMinimumValue = this.bt;
            n.actualMaximumValue = this.bs;
            for (let o = 0; o < g.count; o++) {
                let p = g._inner[o].c;
                if (this.formatLabel == null) {
                    p = (Math.round(p * 100) / 100);
                }
                let q = (p).toString();
                if (this.aj != null) {
                    q = this.aj.i(p);
                }
                m.value = p;
                n.value = p;
                m.label = q;
                if (this.formatLabel != null && this.bb) {
                    this.formatLabel(this, m);
                }
                q = m.label;
                n.label = q;
                let r = this.view.ct(((() => {
                    let $ret = new TextBlock();
                    $ret.al = q;
                    return $ret;
                })()));
                n.width = r.width;
                n.height = r.height;
                if (this.as == 0) {
                    n.offsetX = -1 * (r.width / 2);
                    n.offsetY = -1 * (r.height);
                }
                else {
                    n.offsetX = -1 * r.width;
                    n.offsetY = -1 * (r.height / 2);
                }
                if (this.alignLabel != null && this.bb) {
                    this.alignLabel(this, n);
                }
                if (this.bb) {
                    b.f[o] = n.width;
                    b.c[o] = n.height;
                }
                else {
                    b.f[o] = 0;
                    b.c[o] = 0;
                }
                b.g[o] = n.offsetX;
                b.h[o] = n.offsetY;
                b.d[o] = q;
                b.e[o] = g._inner[o].d;
            }
        }
        bf(a, b, c) {
            let d = c / 10000;
            if (isNaN_(d)) {
                d = 1E-05;
            }
            let e = Math.abs(a - b);
            if (e < d) {
                return true;
            }
            return false;
        }
        fo() {
            let a = this.am;
            let b = a.a;
            b.e = this.h0;
            b.f = this.h1;
            b.c = this.bx;
            b.a = this.bv;
            b.b = this.bw;
        }
        fr() {
            let a = this.am;
            let b = a.b;
            let c = this.ar;
            b.e = this.cq;
            b.b = this.cq;
            b.f = this.cr;
            b.c = this.cr;
            b.i = this.h7;
            b.j = this.h8;
            b.h = this.cs;
            if (isNaN_(this.co)) {
                return;
            }
            let d = c.i(this.co);
            let e = (this.cp / 2);
            b.g = d - e;
            b.d = d + e;
        }
        fs() {
            let a = this.am.c;
            let b = this.c1;
            if (isNaN_(b)) {
                return;
            }
            let c = !(this.a1 == 0 || this.a1 == 5);
            a.ag = this.aq(b, false, c);
            let d = this.b0;
            if (c && !isNaN_(d)) {
                a.af = this.aq(d, true, false);
            }
        }
        aq(a, b, c) {
            let d = this.ar;
            let e = this.bt;
            if (isNaN_(e)) {
                e = this.bt;
            }
            let f = a;
            let g = new LinearGraphRectFrame();
            let h = this.ia;
            let i = this.ib;
            if (c) {
                h = BrushUtil.s(h, this.br);
                i = BrushUtil.s(i, this.br);
            }
            g.i = h;
            g.j = i;
            g.h = this.c4;
            g.g = d.i(e);
            g.d = d.i(f);
            g.e = this.c2;
            g.b = this.c2;
            g.f = this.c3;
            g.c = this.c3;
            return g;
        }
        h3(a, b) {
            if (b != null && b.count > 0) {
                return b.item(a % b.count);
            }
            else {
                return null;
            }
        }
        f3(a) {
            let b = this.ii;
            let c = a.c;
            let d = this.a5;
            let e = c.j;
            let f = c.w;
            let g = c.v;
            let h = c.ad;
            let i = c.x;
            let j = this.a3;
            let k = c.i;
            let l = c.p;
            let m = c.o;
            let n = c.ac;
            let o = c.q;
            d.f = true;
            for (let p = 0; p < this.bi.count; p++) {
                d.n(this.bi._inner[p]);
            }
            this.bi.clear();
            let q = this.cj();
            let r = this.c6();
            for (let s = 0; s < e.length; s++) {
                let t, u, v, w;
                if (this.as == 1) {
                    t = b.left + q * f;
                    u = r - e[s];
                    v = b.left + q * g;
                    w = u;
                }
                else {
                    t = b.left + e[s];
                    u = q * (1 - f);
                    v = t;
                    w = q * (1 - g);
                }
                let x = d.a();
                let y = new PathGeometry();
                let z = new PathFigure();
                z._startPoint = { $type: Point_$type, x: t, y: u };
                z._segments.add(((() => {
                    let $ret = new LineSegment(1);
                    $ret.c = { $type: Point_$type, x: v, y: w };
                    return $ret;
                })()));
                y.c.add(z);
                x.an = y;
                x._stroke = h;
                x.ad = i;
                this.bi.add(x);
            }
            for (let aa = 0; aa < k.length; aa++) {
                let ab, ac, ad, ae;
                if (this.as == 1) {
                    ab = b.left + q * l;
                    ac = r - k[aa];
                    ad = b.left + q * m;
                    ae = ac;
                }
                else {
                    ab = k[aa];
                    ac = q * (1 - l);
                    ad = ab;
                    ae = q * (1 - m);
                }
                let af = d.a();
                let ag = new PathGeometry();
                let ah = new PathFigure();
                ah._startPoint = { $type: Point_$type, x: ab, y: ac };
                ah._segments.add(((() => {
                    let $ret = new LineSegment(1);
                    $ret.c = { $type: Point_$type, x: ad, y: ae };
                    return $ret;
                })()));
                ag.c.add(ah);
                af.an = ag;
                af._stroke = n;
                af.ad = o;
                this.bi.add(af);
            }
            d.f = false;
        }
        f0(a) {
            let b = this.ii;
            let c = a.c;
            let d = c.e;
            let e = c.d;
            let f = c.g;
            let g = c.h;
            let h = c.f;
            let i = c.c;
            let j = c.n;
            let k = this.a2;
            k.f = true;
            for (let l = 0; l < this.bg.count; l++) {
                k.n(this.bg._inner[l]);
            }
            this.bg.clear();
            let m = c.ab;
            let n = this.c5();
            let o = this.c6();
            for (let p = 0; p < e.length; p++) {
                let q, r;
                if (this.as == 1) {
                    q = b.left + n * j;
                    r = b.top + o - d[p];
                }
                else {
                    q = b.left + d[p];
                    r = b.top + n * (1 - j);
                }
                let s = k.a();
                s.al = e[p];
                this.view.bq(s, m);
                let t = h[p];
                let u = i[p];
                let v = f[p];
                let w = g[p];
                this.view.bh(s, q + v, r + w);
                if (this.bb) {
                    this.view.a1(s);
                }
                else {
                    this.view.a2(s);
                }
                this.bg.add(s);
            }
            k.f = false;
        }
        f1(a) {
            let b = a.c;
            let c = this.a4;
            c.f = true;
            for (let d = 0; d < this.bh.count; d++) {
                c.n(this.bh._inner[d]);
            }
            this.bh.clear();
            let e = this.cj();
            let f = this.c6();
            let g = this.ic();
            let h = this.view.co();
            h.an = b.ae(g, e, f, this.as);
            for (let i = 0; i < b.m.count; i++) {
                let j = b.m._inner[i];
                let k = c.a();
                k.an = j.k(g, e, f, this.as);
                k._fill = j.i;
                k._stroke = j.j;
                k.ad = j.h;
                this.bh.add(k);
            }
            this.view.bp(this.bh);
            c.f = false;
            let l = this.view.cn();
            l.an = b.l.k(g, e, f, this.as);
            l._fill = b.l.i;
            l._stroke = b.l.j;
            l.ad = b.l.h;
        }
        fz(a) {
            let b = this.ih;
            let c = this.view.cl();
            let d = a.a;
            let e = this.as == 0 ? b.height : b.width;
            let f = this.as == 0 ? b.width : b.height;
            let g = d.g(e, f, this.as);
            c.an = g;
            c._fill = d.e;
            c._stroke = d.f;
            c.ad = d.c;
        }
        f2(a) {
            let b = this.view.cp();
            if (isNaN_(this.co) || this.co < this.bt || this.co > this.bs) {
                b.an = null;
                return;
            }
            let c = a.b;
            let d = this.cj();
            let e = this.c6();
            let f = this.ic();
            let g = c.k(f, d, e, this.as);
            b.an = g;
            b._fill = c.i;
            b._stroke = c.j;
            b.ad = c.h;
        }
        f4(a) {
            let b = this.view.cq();
            let c = this.view.cm();
            let d = this.c1;
            if (d <= this.bt || d > this.bs || isNaN_(d)) {
                b.an = null;
                c.an = null;
                return;
            }
            let e = this.b0;
            let f = this.a1 != 0;
            if (!f || e <= this.bt || e > this.bs || isNaN_(e)) {
                c.an = null;
                f = false;
            }
            let g = a.c;
            let h = this.cj();
            let i = this.c6();
            let j = this.ic();
            let k = g.ag;
            b.an = k.k(j, h, i, this.as);
            b._fill = k.i;
            b._stroke = k.j;
            b.ad = k.h;
            if (f) {
                let l = g.af;
                c.an = l.k(j, h, i, this.as);
                c._fill = l.i;
                c._stroke = l.j;
                c.ad = l.h;
            }
        }
        fn(a, b) {
            this.a8 = true;
            this.view.bo();
        }
        fi(a, b) {
            this.a8 = true;
            this.view.bo();
        }
        cj() {
            if (this.as == 0) {
                return this.bc ? this.ij.height : this.ii.height;
            }
            return this.bc ? this.ij.width : this.ii.width;
        }
        cl() {
            if (this.as == 0) {
                return this.ij.width * (this.ck - this.cn);
            }
            return this.ij.height * (this.ck - this.cn);
        }
        c5() {
            if (this.as == 0) {
                return this.ij.height;
            }
            return this.ij.width;
        }
        c6() {
            if (this.as == 0) {
                return this.ij.width;
            }
            return this.ij.height;
        }
        cm() {
            let a = this.cn;
            if (this.as == 0) {
                if (this.a9) {
                    a = 1 - this.ck;
                }
                return this.ij.left + this.ij.width * a;
            }
            if (this.a9) {
                a = 1 - this.ck;
            }
            return this.ij.top + this.ij.height * a;
        }
        ic() {
            let a = this.ii.left;
            if (this.bc) {
                a = 0;
            }
            let b = this.cn;
            if (this.as == 0) {
                if (this.a9) {
                    b = 1 - this.ck;
                }
                return { $type: Point_$type, x: a + this.ii.width * b, y: this.ii.top };
            }
            if (!this.a9) {
                b = 1 - this.ck;
            }
            return { $type: Point_$type, x: a, y: this.ii.top + this.ii.height * b };
        }
        fl(a, b, c) {
            switch (a) {
                case XamBulletGraph.$$p[52]:
                case XamBulletGraph.$$p[37]:
                case XamBulletGraph.$$p[41]:
                case XamBulletGraph.$$p[0]:
                case XamBulletGraph.$$p[3]:
                case XamBulletGraph.$$p[56]:
                case XamBulletGraph.$$p[44]:
                case XamBulletGraph.$$p[22]:
                    this.view.a5(a, b, c);
                    break;
                case XamBulletGraph.$$p[28]:
                    this.view.ba(b, c);
                    break;
                case XamBulletGraph.$$p[31]:
                    this.view.bb(b, c);
                    break;
            }
            switch (a) {
                case XamBulletGraph.$$p[13]:
                case XamBulletGraph.$$p[14]:
                    if (this.ds != null) {
                        this.aj = new BindingFormatter();
                        this.aj.j = this.ds;
                        this.aj.d = this.ag;
                    }
                    else {
                        this.aj = null;
                    }
                    this.a8 = true;
                    this.view.bo();
                    break;
                case XamBulletGraph.$$p[51]:
                    this.aw.r = this.c8;
                    this.view.bo();
                    break;
                case "TransitionProgress":
                    if (this.c0 >= 1) {
                        this.aw.w();
                        let d = this.am;
                        this.am = this.an;
                        this.an = d;
                        this.fp();
                        this.fr();
                        this.fs();
                        this.fq();
                        this.fo();
                        this.fz(this.am);
                        this.f1(this.am);
                        this.f2(this.am);
                        this.f4(this.am);
                        this.f3(this.am);
                        this.f0(this.am);
                        if (this.a1 == 5) {
                            this.ff();
                            this.view.bo();
                            return;
                        }
                        else if (this.a1 == 2) {
                            this.a1 = 3;
                        }
                    }
                    this.al.d(this.c0, this.an, this.am);
                    this.fz(this.al);
                    this.f1(this.al);
                    this.f2(this.al);
                    this.f4(this.al);
                    this.f3(this.al);
                    this.f0(this.al);
                    this.view.as();
                    break;
                case XamBulletGraph.$$p[57]:
                case XamBulletGraph.$$p[53]:
                case XamBulletGraph.$$p[55]:
                case XamBulletGraph.$$p[52]:
                case XamBulletGraph.$$p[56]:
                case XamBulletGraph.$$p[58]:
                case XamBulletGraph.$$p[37]:
                case XamBulletGraph.$$p[41]:
                case XamBulletGraph.$$p[43]:
                case XamBulletGraph.$$p[36]:
                case XamBulletGraph.$$p[38]:
                case XamBulletGraph.$$p[40]:
                case XamBulletGraph.$$p[0]:
                case XamBulletGraph.$$p[3]:
                case XamBulletGraph.$$p[44]:
                case XamBulletGraph.$$p[22]:
                case XamBulletGraph.$$p[28]:
                case XamBulletGraph.$$p[31]:
                case XamBulletGraph.$$p[20]:
                case XamBulletGraph.$$p[42]:
                case XamBulletGraph.$$p[39]:
                case XamBulletGraph.$$p[29]:
                case XamBulletGraph.$$p[30]:
                case XamBulletGraph.$$p[4]:
                case XamBulletGraph.$$p[1]:
                case XamBulletGraph.$$p[2]:
                case XamBulletGraph.$$p[10]:
                case XamBulletGraph.$$p[15]:
                case XamBulletGraph.$$p[12]:
                case XamBulletGraph.$$p[16]:
                case XamBulletGraph.$$p[17]:
                case XamBulletGraph.$$p[18]:
                case XamBulletGraph.$$p[48]:
                case XamBulletGraph.$$p[49]:
                case XamBulletGraph.$$p[46]:
                case XamBulletGraph.$$p[45]:
                case XamBulletGraph.$$p[47]:
                case XamBulletGraph.$$p[25]:
                case XamBulletGraph.$$p[24]:
                case XamBulletGraph.$$p[23]:
                case XamBulletGraph.$$p[26]:
                case "ScaleBackgroundBrush":
                case "ScaleBackgroundOutline":
                case "ScaleBackgroundThickness":
                    this.a8 = true;
                    this.view.bo();
                    break;
                case XamBulletGraph.$$p[32]:
                    let e = b;
                    let f = c;
                    if (e != null) {
                        let g = e;
                        g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.fw));
                    }
                    if (f != null) {
                        let h = f;
                        h.collectionChanged = delegateCombine(h.collectionChanged, runOn(this, this.fw));
                    }
                    this.a8 = true;
                    this.view.bo();
                    break;
                case XamBulletGraph.$$p[27]:
                case XamBulletGraph.$$p[11]:
                case XamBulletGraph.$$p[21]:
                case XamBulletGraph.$$p[19]:
                case XamBulletGraph.$$p[33]:
                case XamBulletGraph.$$p[34]:
                    this.bt = Math.min(this.b8, this.b7);
                    this.bs = Math.max(this.b8, this.b7);
                    let i = this.cm();
                    this.ar = new LinearGraphScaler(this.bt, this.bs, i, i + this.cl(), this.a9);
                    this.a8 = true;
                    this.view.bo();
                    break;
                case XamBulletGraph.$$p[5]:
                case XamBulletGraph.$$p[6]:
                    this.view.by();
                    this.a8 = true;
                    this.view.bo();
                    break;
                case "PixelScalingRatio":
                    if (isNaN_(DeviceUtils.a(this.cf))) {
                        this.bu = 1;
                    }
                    else {
                        this.bu = DeviceUtils.a(this.cf);
                    }
                    break;
                case "ActualPixelScalingRatio":
                    this.view.bf();
                    break;
                case XamBulletGraph.$$p[9]:
                    {
                        let j = this.az == 2;
                        this.f8();
                        let k = this.az == 2;
                        this.a8 = true;
                        if (!j && k) {
                            this.a1 = 1;
                        }
                        else if (j && !k) {
                            this.a1 = 4;
                        }
                        this.view.bo();
                        break;
                    }
                case XamBulletGraph.$$p[7]:
                    {
                        let l = this.az == 2;
                        this.f8();
                        let m = this.az == 2;
                        this.a8 = true;
                        if (!l && m) {
                            this.a1 = 1;
                        }
                        else if (l && !m) {
                            this.a1 = 4;
                        }
                        this.view.bo();
                        break;
                    }
                case XamBulletGraph.$$p[8]:
                    this.f9();
                    break;
                case "ActualHighlightValueOpacity":
                    this.a8 = true;
                    this.view.bo();
                    break;
            }
            this.fm(a);
        }
        fw(a, b) {
            if (b.oldItems != null) {
                for (let c of fromEn(b.oldItems)) {
                    c.propertyChanged = delegateRemove(c.propertyChanged, runOn(this, this.fv));
                }
            }
            if (b.newItems != null) {
                for (let d of fromEn(b.newItems)) {
                    d.propertyChanged = delegateCombine(d.propertyChanged, runOn(this, this.fv));
                }
            }
            this.a8 = true;
            this.view.bo();
        }
        fv(a, b) {
            this.a8 = true;
            this.view.bo();
        }
        refresh() {
            this.a8 = true;
            this.view.bo();
        }
        ax() {
            return FontUtil.toFontInfo(this.view.ag, this.di);
        }
    }
    XamBulletGraph.$t = markType(XamBulletGraph, 'XamBulletGraph', Control.$, [INotifyPropertyChanged_$type]);
    XamBulletGraph.g7 = DependencyProperty.i("ScaleBackgroundBrush", Brush.$, XamBulletGraph.$, new PropertyMetadata(2, null, (a, b) => a.fl("ScaleBackgroundBrush", b.oldValue, b.newValue)));
    XamBulletGraph.g8 = DependencyProperty.i("ScaleBackgroundOutline", Brush.$, XamBulletGraph.$, new PropertyMetadata(2, null, (a, b) => a.fl("ScaleBackgroundOutline", b.oldValue, b.newValue)));
    XamBulletGraph.g9 = DependencyProperty.i("ScaleBackgroundThickness", Number_$type, XamBulletGraph.$, new PropertyMetadata(2, 1, (a, b) => a.fl("ScaleBackgroundThickness", b.oldValue, b.newValue)));
    XamBulletGraph.$$p = markDep(DependencyProperty, PropertyMetadata, XamBulletGraph, 'fl', ['BackingBrush:h0:ga', [Brush.$, null], 'BackingInnerExtent:bv:gb', [1, 0], 'BackingOuterExtent:bw:gc', [1, 1], 'BackingOutline:h1:gd', [Brush.$, null], 'BackingStrokeThickness:bx:ge', [1, 2], 'FontBrush:h2:gf', [Brush.$, null], 'Font:di:gg', [2, null], 'HighlightValueDisplayMode:a0:gh', [HighlightedValueDisplayMode_$type, enumGetBox(HighlightedValueDisplayMode_$type, 0)], 'HighlightValueOpacity:b1:gi', [1, 0.5], 'HighlightValue:b0:gj', [1, NaN], 'Interval:b2:gk', [1, NaN], 'IsScaleInverted:a9:gl', [0, false], 'LabelExtent:b3:gm', [1, 0], 'LabelFormat:ds:gn', [2, null], 'LabelFormatSpecifiers:ag:go', [Array_$type, null], 'LabelInterval:b4:gp', [1, NaN], 'LabelsPostInitial:b5:gq', [1, 0], 'LabelsPreTerminal:b6:gr', [1, 0], 'LabelsVisible:bb:gs', [0, true], 'MaximumValue:b7:gt', [1, 100], 'MergeViewports:bc:gu', [0, false], 'MinimumValue:b8:gv', [1, 0], 'MinorTickBrush:h4:gw', [Brush.$, null], 'MinorTickCount:b9:gx', [1, 3], 'MinorTickEndExtent:ca:gy', [1, 0.2], 'MinorTickStartExtent:cc:gz', [1, 0.1], 'MinorTickStrokeThickness:ce:g0', [1, 1], 'Orientation:as:g1', [LinearScaleOrientation_$type, enumGetBox(LinearScaleOrientation_$type, 0)], 'RangeBrushes:ah:g2', [BrushCollection.$, null], 'RangeInnerExtent:cg:g3', [1, 0.2], 'RangeOuterExtent:ch:g4', [1, 0.95], 'RangeOutlines:ai:g5', [BrushCollection.$, null], 'Ranges::g6', [LinearGraphRangeCollection.$, null], 'ScaleEndExtent:ck:ha', [1, 0.95], 'ScaleStartExtent:cn:hb', [1, 0.05], 'ShowToolTipTimeout:c7:hc', [1, 500], 'TargetValueBreadth:cp:hd', [1, 3], 'TargetValueBrush:h7:he', [Brush.$, null], 'TargetValueInnerExtent:cq:hf', [1, 0.3], 'TargetValueName:en:hg', [2, null], 'TargetValueOuterExtent:cr:hh', [1, 0.85], 'TargetValueOutline:h8:hi', [Brush.$, null], 'TargetValue:co:hj', [1, NaN], 'TargetValueStrokeThickness:cs:hk', [1, 1], 'TickBrush:h9:hl', [Brush.$, null], 'TickEndExtent:ct:hm', [1, 0.2], 'TickStartExtent:cx:hp', [1, 0.06], 'TickStrokeThickness:cz:hq', [1, 2], 'TicksPostInitial:cv:hn', [1, 0], 'TicksPreTerminal:cw:ho', [1, 0], 'ToolTip::hr', [4, null], 'TransitionDuration:c8:hs', [1, 0], 'ValueBrush:ia:ht', [Brush.$, null], 'ValueInnerExtent:c2:hu', [1, 0.5], 'ValueName:e4:hv', [2, null], 'ValueOuterExtent:c3:hw', [1, 0.65], 'ValueOutline:ib:hx', [Brush.$, null], 'Value:c1:hy', [1, NaN], 'ValueStrokeThickness:c4:hz', [1, 1]]);
    return XamBulletGraph;
})();
/**
 * @hidden
 */
export let XamBulletGraphView = /*@__PURE__*/ (() => {
    class XamBulletGraphView extends Base {
        constructor(a) {
            super();
            this.ao = 0;
            this.an = 0;
            this.ap = 0;
            this.m = null;
            this.i = null;
            this.ai = null;
            this.p = null;
            this.ag = null;
            this.aa = null;
            this.z = null;
            this.y = null;
            this.ab = null;
            this.ck = null;
            this.cg = null;
            this.cj = null;
            this.ci = null;
            this.cf = null;
            this.ch = null;
            this.b7 = null;
            this.b8 = null;
            this.b4 = null;
            this.b5 = null;
            this.b9 = null;
            this.ca = null;
            this.b6 = null;
            this.c = null;
            this.d = null;
            this.e = null;
            this.f = null;
            this.cb = null;
            this.cc = null;
            this.q = false;
            this.v = null;
            this.a = ["value", "targetvalue", "backing", "scale", "tick", "minortick", "label"];
            this.u = false;
            this.t = false;
            this.ah = null;
            this.k = null;
            this.aj = 0;
            this.al = 0;
            this.aq = null;
            this.am = -1;
            this.cd = null;
            this.ak = 0;
            this.x = null;
            this.b3 = ((() => {
                let $ret = new Brush();
                $ret.fill = "black";
                return $ret;
            })());
            this.r = false;
            this.n = null;
            this.b2 = null;
            this.ac = 0;
            this.m = a;
            this.v = new Dictionary$2(String_$type, Dictionary$2.$.specialize(String_$type, Brush.$), 0);
            this.cj = new Path();
            this.ck = new Path();
            this.cg = new Path();
            this.ci = new Path();
            this.cf = new Path();
            this.ch = new Path();
            this.aa = new List$1(Path.$, 0);
            this.z = new List$1(Path.$, 0);
            this.y = new List$1(TextBlock.$, 0);
            this.ab = new List$1(TextBlock.$, 0);
        }
        a4() {
            this.a0();
            if (this.i != null) {
                this.i.au(this.ag.rootWrapper, "");
            }
        }
        a8() {
            if (this.i != null && this.ag != null) {
                this.i.bi(this.ag.rootWrapper, "");
            }
        }
        a9() {
            this.k = new LinearGraphTooltipDataContext();
            this.ak = this.m.c7;
            this.a0();
        }
        a0() {
            let a = CanvasScalingHelpers.b(this.ag);
            this.m.bu = CanvasScalingHelpers.a(this.m.cf, this.m.bu, a);
            if (this.i != null) {
                CanvasScalingHelpers.h(this.i, a);
            }
        }
        s() {
            return true;
        }
        cp() {
            return this.cj;
        }
        cq() {
            return this.ck;
        }
        cm() {
            return this.cg;
        }
        co() {
            return this.ci;
        }
        cl() {
            return this.cf;
        }
        cn() {
            return this.ch;
        }
        ay() {
            this.q = true;
            let a = ["#778899", "black", "#EBEDEF", "#617583", "#617583", "rgba(100,107,114,.74)", "rgba(100,107,114,.74)"];
            let b = ["#778899", "black", "#B2B9C0", "#B2B9C0", null, null, null];
            let c = ((() => {
                let $ret = new List$1(Array_$type, 0);
                $ret.add(a);
                $ret.add(b);
                return $ret;
            })());
            this.v.clear();
            let d = this.a.length;
            for (let e = 0; e < d; e++) {
                let f = this.a[e];
                let g = "ui-bulletgraph-" + f;
                let h = "ui-bulletgraph-" + f + "-fill";
                let i = "ui-bulletgraph-" + f + "-outline";
                let j;
                if (!((() => { let k = XamBulletGraphView.w.tryGetValue(h, j); j = k.p1; return k.ret; })())) {
                    j = BrushUtil.m(h, g, "background-color", this.ag, a[e]);
                    XamBulletGraphView.w.addItem(h, j);
                }
                let k;
                if (!((() => { let l = XamBulletGraphView.w.tryGetValue(i, k); k = l.p1; return l.ret; })())) {
                    k = BrushUtil.m(i, g, "border-top-color", this.ag, b[e]);
                    XamBulletGraphView.w.addItem(i, k);
                }
                let l = new Dictionary$2(String_$type, Brush.$, 0);
                l.item("fill", j);
                l.item("outline", k);
                this.v.item(this.a[e], l);
            }
            this.bx();
            if (XamBulletGraphView.g == null || XamBulletGraphView.h == null) {
                let m = BrushUtil.i("ui-bulletgraph-range-fill-palette-", "ui-bulletgraph-range-outline-palette-", "ui-bulletgraph-range-palette-", this.ag, XamBulletGraphView.g, XamBulletGraphView.h, ["#216E99", "#216E99", "#44acd6", "#44acd6", "#cecece", "#cecece"]);
                XamBulletGraphView.g = m.p4;
                XamBulletGraphView.h = m.p5;
            }
            this.c = XamBulletGraphView.g;
            this.d = XamBulletGraphView.h;
            if (this.e == null) {
                this.m.ah = this.c;
            }
            if (this.f == null) {
                this.m.ai = this.d;
            }
            this.q = false;
        }
        bx() {
            this.q = true;
            let a = this.a.length;
            for (let b = 0; b < a; b++) {
                let c = this.a[b];
                this.bw(c, this.v.item(c));
            }
            this.q = false;
        }
        bw(a, b) {
            let c = b.item("fill");
            let d = b.item("outline");
            switch (a) {
                case "targetvalue":
                    if (this.b7 == null) {
                        this.m.h7 = c;
                    }
                    if (this.b8 == null) {
                        this.m.h8 = d;
                    }
                    break;
                case "value":
                    if (this.cb == null) {
                        this.m.ia = c;
                    }
                    if (this.cc == null) {
                        this.m.ib = d;
                    }
                    break;
                case "backing":
                    if (this.b4 == null) {
                        this.m.h0 = c;
                    }
                    if (this.b5 == null) {
                        this.m.h1 = d;
                    }
                    break;
                case "tick":
                    if (this.ca == null) {
                        this.m.h9 = c;
                    }
                    break;
                case "minortick":
                    if (this.b6 == null) {
                        this.m.h4 = c;
                    }
                    break;
                case "label":
                    this.b3 = c;
                    break;
            }
        }
        a5(a, b, c) {
            let d = b;
            let e = c;
            if (!this.q) {
                switch (a) {
                    case XamBulletGraph.$$p[37]:
                        this.b7 = e;
                        break;
                    case XamBulletGraph.$$p[41]:
                        this.b8 = e;
                        break;
                    case XamBulletGraph.$$p[0]:
                        this.b4 = e;
                        break;
                    case XamBulletGraph.$$p[3]:
                        this.b5 = e;
                        break;
                    case XamBulletGraph.$$p[52]:
                        this.cb = e;
                        break;
                    case XamBulletGraph.$$p[56]:
                        this.cc = e;
                        break;
                    case XamBulletGraph.$$p[44]:
                        this.ca = e;
                        break;
                    case XamBulletGraph.$$p[22]:
                        this.b6 = e;
                        break;
                }
                if (e == null) {
                    this.bx();
                }
            }
        }
        ba(a, b) {
            if (!this.q) {
                this.e = b;
                if (this.e == null) {
                    this.m.ah = this.c;
                }
            }
        }
        bb(a, b) {
            if (!this.q) {
                this.f = b;
                if (this.f == null) {
                    this.m.ai = this.d;
                }
            }
        }
        b(a, b) {
            this.ag.startCSSQuery();
            for (let c = 0; c < b.length; c++) {
                b[c] = this.ag.getCssDefaultPropertyValue(a, b[c]);
            }
            this.ag.endCSSQuery();
            return b;
        }
        bs() {
            this.ay();
            this.by();
            this.bo();
        }
        ce(a) {
            let b = CanvasGestureDOMEventProxy.c5(this.ag.rootWrapper);
            return { $type: Point_$type, x: a.x - b.left, y: a.y - b.top };
        }
        br(a, b, c, d) {
            this.cd = a;
            this.am = c;
            this.aq = d;
            this.bn();
            this.al = window.setTimeout(runOn(this, this.bz), this.ak);
            this.t = true;
        }
        az() {
            if (this.t) {
                window.clearTimeout(this.al);
                this.t = false;
            }
            if (this.u) {
                let a = this.m.toolTip;
                window.clearTimeout(this.aj);
                a.hide();
                this.u = false;
                this.k = null;
            }
            this.ak = this.m.c7;
        }
        bn() {
            if (this.t) {
                window.clearTimeout(this.al);
            }
            if (this.u) {
                let a = this.m.toolTip;
                window.clearTimeout(this.aj);
                a.hide();
                this.u = false;
                this.ak = intDivide(this.m.c7, 2);
            }
        }
        bz() {
            if (this.t) {
                window.clearTimeout(this.al);
                this.t = false;
            }
            let a = this.am;
            let b = this.aq;
            let c = this.cd;
            if (this.ag != null) {
                this.aj = this.ag.setTimeout(runOn(this, this.az), 10 * this.m.c7);
            }
            else {
                this.aj = window.setTimeout(runOn(this, this.az), 10 * this.m.c7);
            }
            let d = this.m.ranges._inner[a];
            if (this.ah != this.m.toolTip) {
                if (this.ah != null) {
                    this.ah.remove();
                }
                this.ah = this.m.toolTip;
                this.ah.setStyleProperty("z-index", "10000");
                this.ah.setStyleProperty("position", "absolute");
                this.ag.append(this.ah);
            }
            this.k = this.j(b, a);
            let context_ = this.k;
            let tooltip_ = this.ah;
            let tooltipType_ = b;
            if (tooltip_.updateToolTip) {
                tooltip_.updateToolTip(context_, tooltipType_);
            }
            ;
            let e = this.ah.findByClass(".ui-tooltip-container");
            if (e != null && e.length > 0) {
                e[0].setAttribute("style", null);
            }
            let f = "ui-simple-default-tooltip-content";
            let g = this.ah.findByClass("." + f);
            if (g != null && g.length > 0) {
                let h = ["border-top-color", "border-top-width", "border-top-style", "border-top-left-radius", "background-color", "padding-top", "font-weight"];
                let i = ["border-color", "border-width", "border-style", "border-radius", "background-color", "padding", "font-weight"];
                let j = ((() => {
                    let $ret = new List$1(String_$type, 0);
                    $ret.add(this.k.brush.color.colorString);
                    $ret.add("2px");
                    $ret.add("solid");
                    $ret.add("4px");
                    $ret.add("rgba(230, 230, 230, 0.74)");
                    $ret.add("4px");
                    $ret.add("bold");
                    return $ret;
                })());
                let k = new Dictionary$2(String_$type, String_$type, 0);
                let l = new Array(h.length);
                arrayCopy1(h, 0, l, 0, h.length);
                this.b(f, l);
                for (let m = 0; m < l.length; m++) {
                    this.ah.setStyleProperty(i[m], (l[m] == null) ? j._inner[m] : l[m]);
                }
            }
            this.ah.setStyleProperty("top", (c.y + 15).toString() + "px").setStyleProperty("left", (c.x + 15).toString() + "px");
            this.ah.show();
            this.u = true;
        }
        j(a, b) {
            let c = new LinearGraphTooltipDataContext();
            switch (a) {
                case "range":
                    let d = this.m.ranges._inner[b];
                    c.item = d;
                    c.itemName = d.u;
                    c.label = d.u + ": " + d.o.toString() + "-" + d.j.toString();
                    let e = d.an;
                    let f = d.ao;
                    c.brush = e != null ? e : this.m.h3(b, this.c);
                    c.outline = f != null ? f : this.m.h3(b, this.d);
                    c.thickness = d.p;
                    break;
                case "value":
                    c.item = this.m.c1;
                    c.itemName = this.m.e4;
                    c.label = this.m.e4 != null ? this.m.e4 + ": " + this.m.c1.toString() : this.m.c1.toString();
                    c.brush = this.m.ia;
                    c.outline = this.m.ib;
                    c.thickness = this.m.c4;
                    break;
                case "targetvalue":
                    c.item = this.m.co;
                    c.itemName = this.m.en;
                    c.label = this.m.en != null ? this.m.en + ": " + this.m.co.toString() : this.m.co.toString();
                    c.brush = this.m.h7;
                    c.outline = this.m.h8;
                    c.thickness = this.m.cs;
                    break;
            }
            return c;
        }
        a6(a) {
            if (a == null) {
                this.ai = null;
                this.ag = null;
                this.ah = null;
                this.p = null;
                if (this.m.a7) {
                    this.m.aw.w();
                }
                this.at();
                return;
            }
            let b = a;
            this.ag = b;
            this.m.aw.u(this.ag);
            this.ag.rootWrapper.addClass("ui-bulletgraph-container");
            this.ap = (isNaN_(this.m.cf) ? this.m.bu : this.m.cf);
            let c = this.ap;
            let d = Math.round(b.rootWrapper.width());
            let e = Math.round(b.rootWrapper.height());
            let f = d * c;
            let g = e * c;
            this.ag.rootWrapper.setStyleProperty("position", "relative");
            let h = this.ag.createElement("canvas");
            h.setStyleProperty("position", "absolute");
            this.ag.append(h);
            this.ao = f;
            this.an = g;
            h.setAttribute("width", f.toString());
            h.setAttribute("height", g.toString());
            h.setStyleProperty("width", d.toString());
            h.setStyleProperty("height", e.toString());
            h.setStyleProperty("left", "0px");
            h.setStyleProperty("top", "0px");
            this.m.ij = new Rect(0, 0, 0, d, e);
            this.m.ih = new Rect(0, 0, 0, d, e);
            this.ai = h;
            let i = this.ag.get2DCanvasContext(this.ai);
            this.p = new RenderingContext(new CanvasViewRenderer(), i);
            this.ay();
            this.by();
            this.p.af(this.n);
            this.at();
            if (TypeRegistrar.isRegistered("CanvasGestureDOMEventProxy")) {
                this.i = typeCast(EventProxy.$, TypeRegistrar.create("CanvasGestureDOMEventProxy", this.ag.rootWrapper, this.ag, false));
            }
            if (this.i != null) {
                let j = this.i;
                j.onMouseOver = delegateCombine(j.onMouseOver, runOn(this, this.av));
                let k = this.i;
                k.onMouseLeave = delegateCombine(k.onMouseLeave, runOn(this, this.au));
            }
            this.bm();
        }
        at() {
            if (this.i != null) {
                let a = this.i;
                a.onMouseOver = delegateRemove(a.onMouseOver, runOn(this, this.av));
                let b = this.i;
                b.onMouseLeave = delegateRemove(b.onMouseLeave, runOn(this, this.au));
                this.i.aw();
            }
        }
        av(a, b, c) {
            if (this.m != null) {
                this.m.onMouseOver(a, b, c);
            }
        }
        au(a) {
            if (this.m != null) {
                this.m.onMouseLeave();
            }
        }
        a7() {
            this.a0();
            let a = Math.round(this.ag.rootWrapper.width());
            let b = Math.round(this.ag.rootWrapper.height());
            this.m.ij = new Rect(0, 0, 0, a, b);
            this.m.ih = new Rect(0, 0, 0, a, b);
            if (this.i != null) {
                this.i.bm = this.m.ij;
            }
        }
        as() {
            this.bm();
        }
        bp(a) {
            this.x = a;
        }
        bm() {
            let a = this.m.ij.width;
            let b = this.m.ij.height;
            let c = a * this.ap;
            let d = b * this.ap;
            if (this.ao != c || this.an != d) {
                this.ai.setAttribute("width", c.toString());
                this.ai.setAttribute("height", d.toString());
                this.ai.setStyleProperty("width", a.toString() + "px");
                this.ai.setStyleProperty("height", b.toString() + "px");
                this.ao = truncate(Math.round(c));
                this.an = truncate(Math.round(d));
            }
            if (this.p.d && this.ap != 1) {
                this.p.aa();
                this.p.ab(this.ap, this.ap);
            }
            this.p.l(this.m.ij.left, this.m.ij.top, this.m.ij.width, this.m.ij.height);
            this.p.t(this.cf);
            this.p.t(this.ch);
            if (this.x != null) {
                for (let e = 0; e < this.x.count; e++) {
                    this.p.t(this.x._inner[e]);
                }
            }
            for (let f = 0; f < this.y.count; f++) {
                this.p.af(this.n);
                this.p.x(this.y._inner[f]);
            }
            for (let g = 0; g < this.z.count; g++) {
                this.p.t(this.z._inner[g]);
            }
            this.p.t(this.ck);
            this.p.t(this.cg);
            this.p.t(this.cj);
            if (this.p.d && this.ap != 1) {
                this.p.z();
            }
        }
        by() {
            if (this.m.di != null) {
                this.n = this.m.ax();
            }
            else {
                this.n = FontUtil.getFont(this.ag);
            }
            this.ac = this.ad(this.n);
            if (this.m.h2 == null) {
                let a = this.ag.rootWrapper.getStyleProperty("color");
                if (stringIsNullOrEmpty(a) == false) {
                    this.b2 = new Brush();
                    this.b2._fill = a;
                    this.m.h2 = this.b2;
                }
            }
            if (this.p != null) {
                this.p.af(this.n);
            }
        }
        ae(a) {
            let b = typeCast(TextBlock.$, a);
            if (b != null && b.al != null) {
                return this.p.f(b) + 0;
            }
            return 0;
        }
        ct(a) {
            if (isNaN_(this.ac)) {
                this.ac = this.ad(null);
            }
            let b = this.ae(a);
            let c = this.ac;
            return new Size(1, b, c);
        }
        bq(a, b) {
            if (b != null) {
                a.ao = b;
            }
            else {
                a.ao = this.b3;
            }
        }
        bh(a, b, c) {
            a.n = b;
            a.o = c;
        }
        bg(a, b) {
        }
        bi(a, b) {
        }
        ad(a) {
            return FontUtil.getCurrentFontHeight(this.ag, a);
        }
        bo() {
            if (!this.r) {
                this.r = true;
                if (this.ag != null) {
                    this.ag.setTimeout(runOn(this, this.ar), 0);
                }
                else {
                    window.setTimeout(runOn(this, this.ar), 0);
                }
            }
        }
        ar() {
            if (this.r) {
                this.r = false;
                this.m.fb();
            }
        }
        flush() {
            if (this.r) {
                this.ar();
            }
        }
        o(a, b) {
            return FontUtil.getFontInfo(this.ag, a, b);
        }
        aw(a) {
            a.scalePath = new PathVisualData(1, "Scale", this.ci);
            a.targetValuePath = new PathVisualData(1, "TargetValue", this.cj);
            a.valuePath = new PathVisualData(1, "Value", this.ck);
            a.highlightValuePath = new PathVisualData(1, "HighlightValue", this.cg);
            a.backingPath = new PathVisualData(1, "Backing", this.cf);
            a.scaleBackgroundPath = new PathVisualData(1, "ScaleBackground", this.ch);
            let b = this.n;
            for (let c of fromEnum(this.y)) {
                if (c._visibility == 0) {
                    let d = this.o(c, b);
                    let e = new LinearGraphScaleLabelVisualData();
                    e.labelValue = c.al;
                    e.labelPosition = PointData.b({ $type: Point_$type, x: c.n, y: c.o });
                    e.labelSize = SizeData.b(this.ct(c));
                    e.appearance = AppearanceHelper.c(c, d);
                    a.scaleLabels.add(e);
                }
            }
            for (let f of fromEnum(this.z)) {
                if (f._visibility == 0) {
                    let g = new LinearGraphScaleTickmarkVisualData();
                    g.tickPath = new PathVisualData(1, "tickmarks", f);
                    a.scaleTickmarks.add(g);
                }
            }
            for (let h of fromEnum(this.x)) {
                if (h._visibility == 0) {
                    let i = new LinearGraphRangeVisualData();
                    let j = new PathVisualData(1, "range", h);
                    i.rangePath = j;
                    a.ranges.add(i);
                }
            }
        }
        bj(a) {
            a._visibility = 0;
        }
        bk(a) {
            a._visibility = 1;
        }
        bl(a) {
            this.aa.remove(a);
        }
        cs() {
            let a = new Path();
            this.aa.add(a);
            return a;
        }
        bt(a) {
            a._visibility = 0;
        }
        bu(a) {
            a._visibility = 1;
        }
        bv(a) {
            this.ab.remove(a);
        }
        b1() {
            let a = new TextBlock();
            this.ab.add(a);
            return a;
        }
        bc(a) {
            a._visibility = 0;
        }
        bd(a) {
            a._visibility = 1;
        }
        be(a) {
            this.z.remove(a);
        }
        cr() {
            let a = new Path();
            this.z.add(a);
            return a;
        }
        a1(a) {
            a._visibility = 0;
        }
        a2(a) {
            a._visibility = 1;
        }
        a3(a) {
            this.y.remove(a);
        }
        b0() {
            let a = new TextBlock();
            this.y.add(a);
            return a;
        }
        l() {
            if (this.k == null) {
                return null;
            }
            return ((() => {
                let $ret = new ToolTipInfo();
                $ret.b = this.am;
                $ret.d = this.cd;
                $ret.c = this.aq;
                $ret.a = this.k;
                return $ret;
            })());
        }
        bf() {
            this.ap = this.m.bu;
        }
    }
    XamBulletGraphView.$t = markType(XamBulletGraphView, 'XamBulletGraphView');
    XamBulletGraphView.w = new Dictionary$2(String_$type, Brush.$, 0);
    XamBulletGraphView.g = null;
    XamBulletGraphView.h = null;
    return XamBulletGraphView;
})();