/*
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 { FinancialSeries } from "./FinancialSeries";
import { ITrendLineSeries_$type } from "./ITrendLineSeries";
import { TrendLineType_$type } from "igniteui-react-core";
import { DependencyProperty } from "igniteui-react-core";
import { Brush } from "igniteui-react-core";
import { PenLineCap_$type } from "igniteui-react-core";
import { DoubleCollection } from "igniteui-react-core";
import { PriceDisplayType_$type } from "./PriceDisplayType";
import { Series } from "./Series";
import { Defaults } from "./Defaults";
import { enumGetBox, EnumUtil, Number_$type, typeCast, fromEnum, runOn, Point_$type, markType, markDep } from "igniteui-react-core";
import { CategoryFrame } from "./CategoryFrame";
import { ISortingAxis_$type } from "./ISortingAxis";
import { FinancialSeriesView } from "./FinancialSeriesView";
import { Rect } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { RectUtil } from "igniteui-react-core";
import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory";
import { AxisRange } from "./AxisRange";
import { ScalerParams } from "./ScalerParams";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { Pool$1 } from "igniteui-react-core";
import { Path } from "igniteui-react-core";
import { Thickness } from "igniteui-react-core";
import { PathGeometry } from "igniteui-react-core";
import { PathFigure } from "igniteui-react-core";
import { LineSegment } from "igniteui-react-core";
import { GeometryGroup } from "igniteui-react-core";
import { LineGeometry } from "igniteui-react-core";
import { RectangleGeometry } from "igniteui-react-core";
import { DataLegendSeriesValueInfo } from "igniteui-react-core";
import { DataLegendSeriesContext } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { truncate, isNaN_, isInfinity } from "igniteui-react-core";
import { boxArray$1 } from "igniteui-react-core";
import { round10N } from "igniteui-react-core";
import { FinancialPriceBucketCalculator } from "./FinancialPriceBucketCalculator";
import { Extensions } from "igniteui-react-core";
/**
 * @hidden
 */
export let FinancialPriceSeries = /*@__PURE__*/ (() => {
    class FinancialPriceSeries extends FinancialSeries {
        bi() {
            return new FinancialPriceSeries();
        }
        get_e7() {
            return true;
        }
        ji() {
            if (!isNaN_(this.jh)) {
                return super.ji();
            }
            return Defaults.k;
        }
        cq() {
            return new FinancialPriceSeriesView(this);
        }
        qw(a) {
            super.qw(a);
            this.aas = a;
        }
        constructor() {
            super();
            this.aau = true;
            this.aav = 0;
            this.aaw = 0;
            this.ab = FinancialPriceSeries.$;
            this.w1 = new CategoryFrame(5);
            this.w3 = new CategoryFrame(5);
            this.wz = new CategoryFrame(5);
        }
        get ab4() {
            return this.c(FinancialPriceSeries.abm);
        }
        set ab4(a) {
            this.h(FinancialPriceSeries.abm, a);
        }
        o8(a, b, c, d) {
            super.o8(a, b, c, d);
            if (this.wx != null && typeCast(ISortingAxis_$type, this.wx) !== null) {
                this.wx.i$i();
            }
            this.aas.b0.e(this.ib);
            if (this.aas.ca) {
                this.aas.b8.g$e(a, b, c, d);
            }
            if (this.xg != null) {
                this.xg.c1();
            }
            this.rm(true);
            if (a == 0 || a == 2 || a == 3 || a == 4) {
                this.aau = true;
            }
            else if (a == 1) {
                for (let e = b; e < b + c; e++) {
                    let f = 0;
                    f += this.xr.item(e);
                    f += this.xs.item(e);
                    f += this.xq.item(e);
                    this.aav += f / 3;
                }
                this.aaw = this.aav / this.xr.count;
            }
        }
        b0() {
            if (this.b1 == 0) {
                return 1;
            }
            else {
                return super.b0();
            }
        }
        wg(a) {
            if (this.wz == null || this.wz.f.count == 0) {
                return Rect.empty;
            }
            let b = this.v0(a);
            let c = this.ct.by;
            let d = this.ct.bx;
            let e = this.getEffectiveViewport1(this.ct);
            let f = this.am(this.wx, this.wz.f, this.yu(this.ct), this.yw(this.ct), a, true);
            let g = f[0];
            let h = f[1];
            let i = Math.abs(b.x - g[0]);
            let j = Math.abs(b.x - h[0]);
            let k = this.aax(this.xe, e);
            k = Math.max(k, 3);
            let l = (k - 1) / 2;
            if (i < j) {
                let m = g[0] - l;
                let n = g[0];
                let o = g[0] + l;
                let p = g[1];
                let q = g[2];
                let r = g[3];
                let s = g[4];
                let t = Math.min(Math.min(Math.min(p, q), r), s);
                let u = Math.max(Math.max(Math.max(p, q), r), s);
                return new Rect(0, m, t, Math.abs(o - m), u - t);
            }
            else {
                let v = h[0] - l;
                let w = h[0];
                let x = h[0] + l;
                let y = h[1];
                let z = h[2];
                let aa = h[3];
                let ab = h[4];
                let ac = Math.min(Math.min(Math.min(y, z), aa), ab);
                let ad = Math.max(Math.max(Math.max(y, z), aa), ab);
                return new Rect(0, v, ac, Math.abs(x - v), ad - ac);
            }
        }
        aar(a, b) {
            let c = a[0] - b;
            let d = a[0];
            let e = a[0] + b;
            let f = a[1];
            let g = a[2];
            let h = a[3];
            let i = a[4];
            let j = Math.min(Math.min(Math.min(f, g), h), i);
            let k = Math.max(Math.max(Math.max(f, g), h), i);
            let l = Math.min(g, h);
            let m = Math.max(g, h);
            let n = Math.min(f, i);
            let o = Math.max(f, i);
            if (this.aat == 1) {
                let p = new Array(3);
                let q = new Rect(0, c, f, b, 0);
                let r = new Rect(0, d, i, b, 0);
                let s = new Rect(0, d, l, 0, m - l);
                p[0] = q;
                p[1] = r;
                p[2] = s;
                return p;
            }
            else {
                let t = new Array(2);
                let u = new Rect(0, d, l, 0, m - l);
                let v = new Rect(0, c, n, b * 2, o - n);
                t[0] = u;
                t[1] = v;
                return t;
            }
        }
        an(a) {
            let b = new List$1(Rect.$, 0);
            let c = this.v0(a);
            let d = this.ct.by;
            let e = this.ct.bx;
            let f = this.getEffectiveViewport1(this.ct);
            let g = this.am(this.wx, this.wz.f, this.yu(this.ct), this.yw(this.ct), a, true);
            let h = g[0];
            let i = g[1];
            let j = Math.abs(c.x - h[0]);
            let k = Math.abs(c.x - i[0]);
            let l = this.aax(this.xe, f);
            l = Math.max(l, 3);
            let m = (l - 1) / 2;
            if (j < k) {
                return this.aar(h, m);
            }
            else {
                return this.aar(i, m);
            }
        }
        gu(a, b) {
            if (this.gx(a, b)) {
                return true;
            }
            return false;
        }
        gx(a, b) {
            let c = this.wh(a);
            if (c.isEmpty) {
                return false;
            }
            let d = RectUtil.r(c, (this.ic / 2) + this.is(b));
            if (d.containsPoint(a)) {
                let e = this.ao(a);
                if (e != null) {
                    for (let f = 0; f < e.length; f++) {
                        let g = e[f];
                        let h = RectUtil.r(g, (this.ic / 2) + this.is(b));
                        if (h.containsPoint(a)) {
                            return true;
                        }
                    }
                }
            }
            return false;
        }
        q4(a, b, c, d) {
            switch (b) {
                case FinancialPriceSeries.$$p[3]:
                case FinancialPriceSeries.$$p[4]:
                case FinancialPriceSeries.$$p[5]:
                case FinancialPriceSeries.$$p[6]:
                case FinancialPriceSeries.$$p[0]:
                case FinancialPriceSeries.$$p[1]:
                case FinancialPriceSeries.$$p[8]:
                case FinancialPriceSeries.$$p[9]:
                    this.qa();
                    break;
                case FinancialSeries.$$p[14]:
                    this.aas.cg();
                    if (this.c9 != null) {
                        this.c9.nq();
                    }
                    break;
                case "TrendLineType":
                    let e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                    if (e != 0) {
                        this.aas.b8 = CategoryTrendLineManagerFactory.a(this.aas.b8, this.wx, this.so, this, this.dp);
                    }
                    break;
            }
            super.q4(a, b, c, d);
            if (this.aas.ca && this.aas.b8 != null && this.aas.b8.g$b(a, b, c, d)) {
                this.rm(false);
                this.qg();
            }
            switch (b) {
                case FinancialPriceSeries.$$p[2]:
                    if (this.so != null) {
                        this.abl();
                        this.sb();
                        this.wz.x();
                        this.z5(this.wz, this.aas);
                    }
                    this.qg();
                    break;
                case "ActualHighlightingMode":
                case "ActualSelectionMode":
                case "ActualFocusMode":
                    this.rm(true);
                    break;
                case "TrendLineBrush":
                    this.ra(b);
                    break;
                case "TrendLineType":
                    this.qg();
                    break;
                case FinancialSeries.$$p[10]:
                case FinancialPriceSeries.$$p[7]:
                    this.qy();
                    break;
            }
        }
        abl() {
            this.aas.ck();
            if (this.cs != null) {
                this.cs.ck();
            }
        }
        ax(a) {
            if (a != null && a == this.xg && this.xs != null && !isNaN_(this.xs.minimum) && this.xr != null && !isNaN_(this.xr.maximum)) {
                return new AxisRange(this.xs.minimum, this.xr.maximum);
            }
            return null;
        }
        ay(a) {
            if (a.isEmpty && this.c9 != null) {
                a = this.c9.vl;
            }
            if (this.xs == null || this.xr == null) {
                return null;
            }
            let b = this.wc(this.ct);
            let c = new ScalerParams(0, a, this.c9.v0, this.wx.ch, this.getEffectiveViewport());
            let d = (this.wx.en(b.left, c));
            let e = (this.wx.en(b.right, c));
            if (this.wx.ch) {
                let f = d;
                d = e;
                e = f;
            }
            let g = null;
            if (this.wx.cn) {
                g = this.wx;
                d = g.i$f(d);
                e = g.i$f(e);
            }
            else {
                d = Math.floor(d);
                e = Math.ceil(e);
            }
            d = Math.max(0, Math.min(this.xs.count - 1, d));
            e = Math.max(0, Math.min(this.xs.count - 1, e));
            let h = 1.7976931348623157E+308;
            let i = -1.7976931348623157E+308;
            for (let j = truncate(d); j <= truncate(e); j++) {
                let k = j;
                if (g != null) {
                    k = g.i$b._inner[j];
                }
                let l = this.xs.item(k);
                if (this.xs.mayContainUnknowns) {
                    if (isInfinity(l) || isNaN_(l)) {
                        continue;
                    }
                }
                let m = this.xr.item(k);
                if (this.xr.mayContainUnknowns) {
                    if (isInfinity(m) || isNaN_(m)) {
                        continue;
                    }
                }
                h = Math.min(h, l);
                i = Math.max(i, m);
            }
            let n = new AxisRange(h, i);
            n = this.aw(n, this.xg, a);
            return n;
        }
        iw() {
            return Series.ix(this.xt, typeCast(ISortingAxis_$type, this.wx));
        }
        gb(a) {
            let b = this.dl != null ? this.dl.indexOf(a) : -1;
            let c = this.ct.by;
            c = c.copy();
            let d = this.ct.bx;
            let e = new Rect(0, 0, 0, 1, 1);
            let f = this.we(this.ct);
            if (b >= 0 && Rect.l_op_Inequality(c, null) && Rect.l_op_Inequality(d, null)) {
                if (this.wx != null) {
                    let g = new ScalerParams(0, e, e, this.wx.ch, f);
                    let h = this.wx.ek(b, g);
                    if (h < c.left + 0.1 * c.width) {
                        h = h + 0.4 * c.width;
                    }
                    if (h > c.right - 0.1 * c.width) {
                        h = h - 0.4 * c.width;
                    }
                    c.x = h - 0.5 * c.width;
                }
                if (this.xg != null && this.xs != null && this.xr != null && b < this.xs.count && b < this.xr.count) {
                    let i = new ScalerParams(0, e, e, this.xg.ch, f);
                    i.b = this.iw();
                    let j = this.xg.ek(this.xs.item(b), i);
                    let k = this.xg.ek(this.xr.item(b), i);
                    if (!isNaN_(j) && !isNaN_(k)) {
                        let l = Math.abs(j - k);
                        if (c.height < l) {
                            c.height = l;
                            c.y = Math.min(j, k);
                        }
                        else {
                            if (j < c.top + 0.1 * c.height) {
                                j = j + 0.4 * c.height;
                            }
                            if (j > c.bottom - 0.1 * c.height) {
                                j = j - 0.4 * c.height;
                            }
                            c.y = j - 0.5 * c.height;
                        }
                    }
                }
                this.c1.au(this.c9, c, true);
            }
            return b >= 0;
        }
        hc(a, b, c) {
            let d = super.hc(a, b, c);
            if (this.xt == null || this.xq == null || this.xr == null || this.xs == null) {
                d = false;
            }
            return d;
        }
        z3(a, b) {
            super.z3(a, b);
            let c = b.by;
            let d = b.bx;
            let e = this.getEffectiveViewport1(b);
            let f = this.wx;
            let g = this.xg;
            let h = new ScalerParams(0, c, d, f.ch, e);
            let i = ((() => {
                let $ret = new ScalerParams(0, c, d, g.ch, e);
                $ret.b = this.iw();
                return $ret;
            })());
            let j = this.wx.ag();
            let k = j[0];
            let l = j[1];
            a.f.clear();
            if (a.m != null) {
                a.m.clear();
            }
            a.n.clear();
            a.q.clear();
            let m = 0;
            let n = typeCast(ISortingAxis_$type, this.wx);
            if (n != null && (n.i$b == null || n.i$b.count != this.dl.count)) {
                return;
            }
            m = this.yo(c, d, e);
            let o = typeCast(FinancialPriceSeriesView.$, b);
            let p = this.ib;
            let q = b.b0.b;
            if (this.trendLineType != 0) {
                let r = new Array(this.dl.count);
                let s = 0;
                for (let t of fromEnum(this.yf)) {
                    r[s] = t;
                    s++;
                }
                if (this.aas.ca) {
                    this.aas.b8.prepareLineCore(a.q, this.trendLineType, boxArray$1(r), this.trendLinePeriod, (u) => this.wx.ek(u, h), (u) => this.xg.ek(u, i), ((() => {
                        let $ret = new TrendResolutionParams();
                        $ret.e = b.b0.b;
                        $ret.f = b.b0.c;
                        $ret.g = b.b0.d;
                        $ret.a = m;
                        $ret.d = p;
                        $ret.i = d;
                        $ret.h = e;
                        $ret.c = k;
                        $ret.b = l;
                        return $ret;
                    })()));
                }
            }
            let u = this.wx.en(2, h) - this.wx.en(1, h);
            for (let v = b.b0.c; v <= b.b0.d; ++v) {
                let w;
                let x = v * q;
                if (n == null) {
                    w = b.b0.getBucket(v);
                }
                else {
                    let y = n.i$b._inner[v];
                    x = y;
                    let z = n.i$d(y);
                    let aa = this.xt.item(y);
                    let ab = this.xr.item(y);
                    let ac = this.xs.item(y);
                    let ad = this.xq.item(y);
                    let ae = aa;
                    let af = ab;
                    let ag = ac;
                    let ah = ad;
                    let ai = z;
                    while (v < b.b0.d) {
                        y = n.i$b._inner[v + 1];
                        ai = n.i$d(y);
                        if (ai - z > u * p) {
                            break;
                        }
                        x = y;
                        v++;
                        af = Math.max(af, this.xr.item(y));
                        ag = Math.min(ag, this.xs.item(y));
                        ah = this.xq.item(y);
                    }
                    let aj = NaN;
                    if (!isNaN_(z)) {
                        aj = this.wx.ek(z, h);
                    }
                    w = [aj, ae, af, ag, ah];
                }
                if (!isNaN_(w[0])) {
                    if (n != null) {
                        w[0] = w[0] + m;
                    }
                    else {
                        w[0] = f.ek(w[0], h) + m;
                    }
                    w[1] = g.ek(w[1], i);
                    w[2] = g.ek(w[2], i);
                    w[3] = g.ek(w[3], i);
                    w[4] = g.ek(w[4], i);
                    if (n != null) {
                        if (a.m == null) {
                            a.m = new List$1(Number_$type, 0);
                        }
                        a.m.add(x);
                    }
                    a.f.add(w);
                }
            }
            return;
        }
        o2(a, b) {
            super.o2(a, b);
            let c = typeCast(FinancialPriceSeriesView.$, b);
            c.ce();
            if (a) {
                c.b9.count = 0;
            }
            if (c.ca && c.b8 != null) {
                c.b8.g$d();
            }
        }
        sj(a, b) {
            super.sj(a, b);
            if (this.c9 != null) {
                this.c9.nq();
            }
        }
        wm(a, b) {
            if (this.wx != null && this.wx.categoryMode == 0) {
                let c = this.getEffectiveViewport1(this.ct);
                let d = this.aax(this.xe, c) / 2;
                return new Thickness(1, d, 0, d, 0);
            }
            return super.wm(a, b);
        }
        get_eb() {
            return true;
        }
        z5(a, b) {
            super.z5(a, b);
            if (this.wx == null || this.xg == null) {
                return;
            }
            let c = false;
            if (b.b3(a)) {
                c = true;
                b.b5(a);
            }
            this.w6.a2(this, this.x5(), runOn(this, this.wp), this.yu(b), this.yw(b));
            let d = false;
            let e = this.w6.b;
            if (e != null) {
                d = true;
            }
            let f = typeCast(FinancialPriceSeriesView.$, b);
            f.cd();
            f.cb = false;
            if (f.ca) {
                f.b8.g$d();
            }
            if (this.trendLineType != 0) {
                f.b8.g$g(a.q);
            }
            if (d) {
                this.abj(a, b, c);
            }
            else {
                f.b9.count = 0;
                this.abi(a, b);
            }
        }
        iu() {
            let a = this.getEffectiveViewport1(this.ct);
            return this.aax(this.xe, a);
        }
        abj(a, b, c) {
            let d = this.aat;
            let e = this.getEffectiveViewport1(b);
            let f = this.aax(b, e);
            let g = (f - 1) / 2;
            let h = typeCast(ISortingAxis_$type, this.wx) !== null;
            let i = typeCast(FinancialPriceSeriesView.$, b);
            i.cb = true;
            let j = a.f;
            let k = 0;
            let l = this.dl.count;
            let m = this.wx;
            let n = new ScalerParams(0, b.by, b.bx, m.ch, e);
            let o = this.u2;
            let p = this.aan;
            if (p == null) {
                p = o;
            }
            let q = this.u6;
            let r = this.ab5;
            if (r == null) {
                r = q;
            }
            for (let s = 0; s < j.count; ++s) {
                let t = j._inner[s][0] - g;
                let u = j._inner[s][0];
                let v = j._inner[s][0] + g;
                let w = j._inner[s][1];
                let x = j._inner[s][2];
                let y = j._inner[s][3];
                let z = j._inner[s][4];
                if (isNaN_(w) || isNaN_(x) || isNaN_(y) || isNaN_(z)) {
                    continue;
                }
                let aa = i.b9.item(k);
                k++;
                let ab = w < z;
                let ac = new PathGeometry();
                if (c) {
                    switch (d) {
                        case 0:
                            if (ab) {
                                let ad = w;
                                w = z;
                                z = ad;
                            }
                            let ae = new PathFigure();
                            ae._startPoint = { $type: Point_$type, x: u, y: y };
                            ae._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: u, y: w };
                                return $ret;
                            })()));
                            let af = new PathFigure();
                            af._startPoint = { $type: Point_$type, x: t, y: z };
                            af._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: v, y: z };
                                return $ret;
                            })()));
                            af._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: v, y: w };
                                return $ret;
                            })()));
                            af._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: t, y: w };
                                return $ret;
                            })()));
                            af._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: t, y: z };
                                return $ret;
                            })()));
                            let ag = new PathFigure();
                            ag._startPoint = { $type: Point_$type, x: u, y: z };
                            ag._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: u, y: x };
                                return $ret;
                            })()));
                            ac.c.add(ae);
                            ac.c.add(af);
                            ac.c.add(ag);
                            break;
                        case 1:
                            let ah = new PathFigure();
                            ah._startPoint = { $type: Point_$type, x: t, y: w };
                            ah._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: u, y: w };
                                return $ret;
                            })()));
                            let ai = new PathFigure();
                            ai._startPoint = { $type: Point_$type, x: u, y: y };
                            ai._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: u, y: x };
                                return $ret;
                            })()));
                            let aj = new PathFigure();
                            aj._startPoint = { $type: Point_$type, x: u, y: z };
                            aj._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: v, y: z };
                                return $ret;
                            })()));
                            ac.c.add(ah);
                            ac.c.add(ai);
                            ac.c.add(aj);
                            break;
                    }
                }
                if (ab) {
                    this.w6.ak = p;
                    this.w6.ag = p;
                    this.w6.ah = r;
                    this.w6.al = r;
                    this.w6.f = true;
                }
                else {
                    this.w6.ak = o;
                    this.w6.ag = o;
                    this.w6.ah = q;
                    this.w6.al = q;
                    this.w6.f = false;
                }
                let ak = this.w6.aw(l, s)[0];
                if (h && a.m != null && s >= 0 && s < a.m.count) {
                    ak = truncate(Math.round(a.m._inner[s]));
                }
                this.z2(j, s, l, m, n, b.q, ak);
                if (d == 1) {
                    this.w6.ad(aa, true, false, false, false);
                }
                else {
                    this.w6.ad(aa, false, false, false, false);
                }
                if (c) {
                    aa.an = ac;
                }
            }
            i.b9.count = k;
            i.cf();
        }
        aax(a, b) {
            let c = this.wx.k5(a.by, a.bx, b);
            c = Math.max(c, this.ib * 0.9);
            c = Math.max(c, 3);
            return c;
        }
        abi(a, b) {
            let c = this.aat;
            let d = this.getEffectiveViewport1(b);
            let e = this.aax(b, d);
            let f = (e - 1) / 2;
            let g = typeCast(FinancialPriceSeriesView.$, b);
            let h = g.cn();
            let i = g.cm();
            let j = a.f;
            for (let k = 0; k < j.count; ++k) {
                let l = j._inner[k][0] - f;
                let m = j._inner[k][0];
                let n = j._inner[k][0] + f;
                let o = j._inner[k][1];
                let p = j._inner[k][2];
                let q = j._inner[k][3];
                let r = j._inner[k][4];
                if (isNaN_(o) || isNaN_(p) || isNaN_(q) || isNaN_(r)) {
                    continue;
                }
                let s = o < r;
                let t = s ? i : h;
                switch (c) {
                    case 0:
                        if (s) {
                            let u = o;
                            o = r;
                            r = u;
                        }
                        t.d.add(((() => {
                            let $ret = new LineGeometry();
                            $ret.d = { $type: Point_$type, x: m, y: q };
                            $ret.c = { $type: Point_$type, x: m, y: o };
                            return $ret;
                        })()));
                        t.d.add(((() => {
                            let $ret = new RectangleGeometry();
                            $ret.e = new Rect(0, l, r, n - l, o - r);
                            return $ret;
                        })()));
                        t.d.add(((() => {
                            let $ret = new LineGeometry();
                            $ret.d = { $type: Point_$type, x: m, y: r };
                            $ret.c = { $type: Point_$type, x: m, y: p };
                            return $ret;
                        })()));
                        break;
                    case 1:
                        t.d.add(((() => {
                            let $ret = new LineGeometry();
                            $ret.d = { $type: Point_$type, x: l, y: o };
                            $ret.c = { $type: Point_$type, x: m, y: o };
                            return $ret;
                        })()));
                        t.d.add(((() => {
                            let $ret = new LineGeometry();
                            $ret.d = { $type: Point_$type, x: m, y: q };
                            $ret.c = { $type: Point_$type, x: m, y: p };
                            return $ret;
                        })()));
                        t.d.add(((() => {
                            let $ret = new LineGeometry();
                            $ret.d = { $type: Point_$type, x: m, y: r };
                            $ret.c = { $type: Point_$type, x: n, y: r };
                            return $ret;
                        })()));
                        break;
                }
            }
        }
        ku(a, b) {
            if (this.aas.ca && a == this.aas.b8.g$j) {
                return null;
            }
            return super.ku(a, b);
        }
        sa() {
            super.sa();
            if (this.index < 0) {
                return;
            }
            this.aas.cl();
        }
        pu(a) {
            super.pu(a);
            if (this.aas.ca) {
                this.bb.exportTrendlineData(this, a, this.aas.b8.g$j);
            }
        }
        vq() {
            return this.ab5;
        }
        rw(a, b) {
            super.rw(a, b);
            this.ab5 = b;
        }
        bd(a) {
            if (this.aat == 0) {
                return 3;
            }
            else if (this.aat == 1) {
                if (this.bc == 1) {
                    return 3;
                }
                return 2;
            }
            return a;
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.i1(c, false, false);
            let e = this.iz(c, false, false);
            let f = new DataLegendSeriesValueInfo();
            f.a = 4;
            f.l = this.yp(c, false, false);
            f.q = "Close";
            f.r = this.y1 != null ? this.y1 : "Close";
            f.s = this.aa0 != null ? this.aa0 : "C:";
            f.t = this.aa2 != null ? this.aa2 : "";
            let g = new DataLegendSeriesValueInfo();
            g.l = this.yq(c, false, false);
            g.a = 3;
            g.q = "Open";
            g.r = this.zn != null ? this.zn : "Open";
            g.s = this.abe != null ? this.abe : "O:";
            g.t = this.abg != null ? this.abg : "";
            g.k = true;
            let h = new DataLegendSeriesValueInfo();
            h.l = (f.l - g.l) / g.l * 100;
            h.l = round10N(h.l, 1);
            h.a = 9;
            h.q = "Change";
            h.r = "Change";
            h.s = "";
            h.v = "";
            h.x = "+";
            h.w = "%";
            h.y = "%";
            h.t = null;
            h.c = false;
            h.k = true;
            h.e = false;
            h.f = true;
            h.h = false;
            h.g = false;
            h.d = false;
            h.n = 1;
            h.m = 1;
            g.z = h.l >= 0 ? this.u2 : this.aan;
            f.z = h.l >= 0 ? this.u2 : this.aan;
            h.z = h.l >= 0 ? this.u2 : this.aan;
            let i = new DataLegendSeriesValueInfo();
            i.l = e > d ? d : e;
            i.a = 1;
            i.q = "Low";
            i.r = this.zj != null ? this.zj : "Low";
            i.s = this.aa9 != null ? this.aa9 : "L:";
            i.t = this.abb != null ? this.abb : "";
            i.k = true;
            let j = new DataLegendSeriesValueInfo();
            j.l = e > d ? e : d;
            j.a = 2;
            j.q = "High";
            j.r = this.ze != null ? this.ze : "High";
            j.s = this.aa5 != null ? this.aa5 : "H:";
            j.t = this.aa7 != null ? this.aa7 : "";
            j.k = true;
            let k = new DataLegendSeriesValueInfo();
            k.l = (j.l + i.l + f.l) / 3;
            k.l = round10N(k.l, 2);
            k.a = 5;
            k.q = "TypicalPrice";
            k.r = "TypicalPrice";
            k.s = "TP:";
            k.t = "";
            k.k = true;
            let l = new DataLegendSeriesValueInfo();
            l.l = this.yr(c, false, false);
            l.a = 8;
            l.q = "Volume";
            l.r = this.zr != null ? this.zr : "Volume";
            l.s = "VOL:";
            l.t = "";
            l.k = true;
            l.n = 0;
            l.m = 0;
            l.e = false;
            l.f = false;
            l.h = false;
            let m = new List$1(DataLegendSeriesValueInfo.$, 0);
            m.add(g);
            m.add(j);
            m.add(i);
            m.add(f);
            m.add(k);
            m.add(h);
            m.add(l);
            let n = new DataLegendSeriesContext();
            n.h = this.l9();
            n.e = m;
            return n;
        }
        abk() {
            if (this.aau) {
                this.aav = 0;
                for (let a = 0; a < this.xr.count; a++) {
                    let b = 0;
                    b += this.xr.item(a);
                    b += this.xs.item(a);
                    b += this.xq.item(a);
                    this.aav += b / 3;
                }
                this.aaw = this.aav / this.xr.count;
                this.aau = false;
            }
        }
        ap(a) {
            let b = NaN;
            switch (a) {
                case 2:
                    b = this.xr.maximum;
                    break;
                case 1:
                    b = this.xs.minimum;
                    break;
                case 3:
                    if (this.aau) {
                        this.abk();
                    }
                    b = this.aaw;
                    break;
            }
            let c = this.xg;
            if (c.cp) {
                return [NaN, b];
            }
            else {
                return [b, NaN];
            }
        }
        v8(a) {
            let b = NaN;
            switch (a) {
                case 2:
                    b = this.xr.maximum;
                    break;
                case 1:
                    b = this.xs.minimum;
                    break;
                case 3:
                    if (this.aau) {
                        this.abk();
                    }
                    b = this.aaw;
                    break;
            }
            if (isNaN_(b)) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            let c = this.xg;
            let d = this.getEffectiveViewport1(this.ct);
            let e = new ScalerParams(0, this.ct.by, this.ct.bx, c.ch, d);
            if (c.cp) {
                e.b = this.iw();
            }
            e.c = d;
            if (c.cp) {
                return { $type: Point_$type, x: NaN, y: c.ek(b, e) };
            }
            else {
                return { $type: Point_$type, x: c.ek(b, e), y: NaN };
            }
        }
        v9(a) {
            let b = this.xg;
            let c = this.getEffectiveViewport1(this.ct);
            let d = new ScalerParams(0, this.ct.by, this.ct.bx, b.ch, c);
            if (b.cp) {
                d.b = this.iw();
            }
            d.c = c;
            if (b.cp) {
                return { $type: Point_$type, x: NaN, y: b.ek(a[1], d) };
            }
            else {
                return { $type: Point_$type, x: b.ek(a[0], d), y: NaN };
            }
        }
    }
    FinancialPriceSeries.$t = /*@__PURE__*/ markType(FinancialPriceSeries, 'FinancialPriceSeries', FinancialSeries.$, [ITrendLineSeries_$type]);
    FinancialPriceSeries.abm = /*@__PURE__*/ DependencyProperty.i("ActualTrendLineBrush", Brush.$, FinancialPriceSeries.$, /*@__PURE__*/ new PropertyMetadata(2, null, (a, b) => a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue)));
    FinancialPriceSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, FinancialPriceSeries, 'raisePropertyChanged', ['CloseMemberAsLegendLabel:aa0:abn', [2, null], 'CloseMemberAsLegendUnit:aa2:abo', [2, null], 'DisplayType:aat:abp', [PriceDisplayType_$type, /*@__PURE__*/ enumGetBox(PriceDisplayType_$type, 0)], 'HighMemberAsLegendLabel:aa5:abq', [2, null], 'HighMemberAsLegendUnit:aa7:abr', [2, null], 'LowMemberAsLegendLabel:aa9:abs', [2, null], 'LowMemberAsLegendUnit:abb:abt', [2, null], 'NegativeOutline:ab5:abu', [Brush.$, null], 'OpenMemberAsLegendLabel:abe:abv', [2, null], 'OpenMemberAsLegendUnit:abg:abw', [2, null], 'TrendLineType::ab2', [TrendLineType_$type, /*@__PURE__*/ enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::ab1', [1, 1.5], 'TrendLinePeriod::ab0', [1, 7], 'TrendLineBrush::abx', [Brush.$, null], 'TrendLineZIndex:aaz:ab3', [1, 1001], 'TrendLineDashArray:ab6:aby', [DoubleCollection.$], 'TrendLineDashCap:ab7:abz', [PenLineCap_$type, /*@__PURE__*/ enumGetBox(PenLineCap_$type, 0)]]);
    return FinancialPriceSeries;
})();
/**
 * @hidden
 */
export let FinancialPriceSeriesView = /*@__PURE__*/ (() => {
    class FinancialPriceSeriesView extends FinancialSeriesView {
        constructor(a) {
            super(a);
            this.b6 = null;
            this.b9 = null;
            this.cc = null;
            this.cq = ((() => {
                let $ret = new Path();
                $ret.an = new GeometryGroup();
                return $ret;
            })());
            this.cp = ((() => {
                let $ret = new Path();
                $ret.an = new GeometryGroup();
                return $ret;
            })());
            this.b7 = null;
            this.co = new Path();
            this.cb = false;
            this.b6 = a;
            this.cc = new List$1(Path.$, 0);
            this.b9 = ((() => {
                let $ret = new Pool$1(Path.$);
                $ret.create = runOn(this, this.cr);
                $ret.activate = runOn(this, this.ch);
                $ret.disactivate = runOn(this, this.cj);
                $ret.destroy = runOn(this, this.ci);
                return $ret;
            })());
        }
        cr() {
            let a = new Path();
            this.cc.add(a);
            a._visibility = 1;
            return a;
        }
        ch(a) {
            a._visibility = 0;
        }
        cj(a) {
            a._visibility = 1;
        }
        ci(a) {
            this.cc.remove(a);
        }
        b1() {
            return new FinancialPriceBucketCalculator(this);
        }
        au() {
            super.au();
            if (!this.q) {
                this.b6.aat = Defaults.g;
                this.b6.aan = Defaults.ah;
                this.b6.ab5 = Defaults.ai;
                this.b6.jn = Defaults.l;
                this.b6.vo = this.b6.u6;
            }
        }
        get b8() {
            if (this.b7 == null) {
                this.b7 = CategoryTrendLineManagerFactory.a(this.b7, this.e.az(), this.e.so, this.e, this.e.dp);
            }
            return this.b7;
        }
        set b8(a) {
            this.b7 = a;
        }
        get ca() {
            return this.b7 != null;
        }
        ck() {
            if (this.b6.aat == 1) {
                this.cq._stroke = this.e.u2;
            }
            else {
                this.cq._stroke = this.e.u6;
            }
            if (this.b6.aat == 1) {
                this.cp._stroke = this.b2.aan;
            }
            else {
                this.cp._stroke = this.b6.ab5;
            }
        }
        ce() {
            this.as();
            this.b9.count = 0;
            this.cd();
        }
        cd() {
            let a = typeCast(GeometryGroup.$, this.cq.an);
            let b = typeCast(GeometryGroup.$, this.cp.an);
            Extensions.d(a);
            Extensions.d(b);
        }
        cn() {
            this.as();
            return typeCast(GeometryGroup.$, this.cq.an);
        }
        cm() {
            this.as();
            return typeCast(GeometryGroup.$, this.cp.an);
        }
        cl() {
            this.b6.ab4 = null;
            if (this.b6.trendLineBrush != null) {
                this.b6.ab4 = this.b6.trendLineBrush;
            }
            else {
                this.b6.ab4 = this.b6.u2;
            }
        }
        bd() {
            super.bd();
            this.cq.ad = this.e.ic;
            this.cq.ai = this.e.vv;
            this.cq.aj = this.e.vw;
            if (this.b6.aat == 1) {
                this.cq._stroke = this.e.u2;
            }
            else {
                this.cq._stroke = this.e.u6;
                this.cq._fill = this.e.u2;
            }
            this.cp.ad = this.e.ic;
            this.cp.ai = this.e.vv;
            this.cp.aj = this.e.vw;
            if (this.b6.aat == 1) {
                this.cp._stroke = this.b2.aan;
            }
            else {
                this.cp._stroke = this.b6.ab5;
                this.cp._fill = this.b2.aan;
            }
        }
        be() {
            super.be();
            let a = this.br();
            this.cq.ad = this.e.ic + 3;
            if (this.b6.aat == 1) {
                this.cq._stroke = a;
            }
            else {
                this.cq._stroke = a;
                this.cq._fill = a;
            }
            this.cp.ad = this.e.ic + 3;
            if (this.b6.aat == 1) {
                this.cp._stroke = a;
            }
            else {
                this.cp._stroke = a;
                this.cp._fill = a;
            }
        }
        ac(a) {
            return this.cc._inner[a];
        }
        ab(a) {
            let b = this.cc._inner[a];
            this.co._visibility = b._visibility;
            this.co.an = b.an;
            let c = this.bs(a);
            this.co._fill = c;
            this.co._stroke = c;
            this.co.ad = this.e.ic + 3;
            return this.co;
        }
        a8(a, b) {
            super.a8(a, b);
            if (a.d) {
                if (this.cb) {
                    for (let c = 0; c < this.cc.count; c++) {
                        let d = this.aa(c, b);
                        if (d._visibility == 0) {
                            a.t(d);
                        }
                    }
                }
                else {
                    a.t(this.cq);
                    a.t(this.cp);
                }
            }
        }
        a7(a, b) {
            if (a.d) {
                if (this.b6.trendLineType != 0 && !b) {
                    let c = this.b8.g$j;
                    c.ad = this.b6.trendLineThickness;
                    c._stroke = this.b6.ab4;
                    c.ai = this.b6.ab6;
                    c.aj = this.b6.ab7;
                    a.v(c);
                }
            }
            super.a7(a, b);
        }
        an(a) {
            super.an(a);
            if (this.b6.x5()) {
                for (let b = 0; b < this.cc.count; b++) {
                    let c = this.cc._inner[b];
                    if (c._fill == this.b6.aan) {
                        this.e.bb.exportPathData(a, c, "negativePathShape" + b, ["Negative"]);
                    }
                    else {
                        this.e.bb.exportPathData(a, c, "positivePathShape" + b, ["Positive", "Main"]);
                    }
                }
            }
            else {
                this.e.bb.exportPathData(a, this.cq, "positivePathShape", ["Positive", "Main"]);
                this.e.bb.exportPathData(a, this.cp, "negativePathShape", ["Negative"]);
            }
        }
        cf() {
            this.as();
        }
        cg() {
            if (this.ca) {
                this.b7 = CategoryTrendLineManagerFactory.a(this.b7, this.e.az(), this.e.so, this.e, this.e.dp);
            }
        }
    }
    FinancialPriceSeriesView.$t = /*@__PURE__*/ markType(FinancialPriceSeriesView, 'FinancialPriceSeriesView', FinancialSeriesView.$);
    return FinancialPriceSeriesView;
})();
