/*
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 { BrushScale } from "./BrushScale";
import { DependencyProperty } from "igniteui-react-core/ES2015/DependencyProperty";
import { Type, typeGetValue, markType } from "igniteui-react-core/ES2015/type";
import { PropertyMetadata } from "igniteui-react-core/ES2015/PropertyMetadata";
import { isNaN_, isInfinity, logBase } from "igniteui-react-core/ES2015/number";
/**
 * @hidden
 */
export class ValueBrushScale extends BrushScale {
    constructor() {
        super();
        this.w = false;
        this.aa = 10;
    }
    getBrushByIndex(a, b) {
        if (b == null || this.brushes == null || this.brushes.count == 0 || a < 0 || a >= b.count) {
            return null;
        }
        if (b.count == 0) {
            return this.brushes.item(0);
        }
        let c = isNaN_(this.minimumValue) || isInfinity(this.minimumValue) ? b.minimum : this.minimumValue;
        let d = isNaN_(this.maximumValue) || isInfinity(this.maximumValue) ? b.maximum : this.maximumValue;
        let e = b.item(a);
        if (c == d) {
            return e == c ? this.brushes.item(0) : null;
        }
        return this.an(c, d, e);
    }
    getBrushByValue(a, b) {
        if (b == null || this.brushes == null || this.brushes.count == 0) {
            return null;
        }
        if (b.count <= 1) {
            return this.brushes.item(0);
        }
        let c = isNaN_(this.minimumValue) || isInfinity(this.minimumValue) ? b.minimum : this.minimumValue;
        let d = isNaN_(this.maximumValue) || isInfinity(this.maximumValue) ? b.maximum : this.maximumValue;
        if (a < c) {
            return null;
        }
        if (a > d) {
            return null;
        }
        return this.an(c, d, a);
    }
    an(a, b, c) {
        if (this.w && this.aa > 0) {
            let d = logBase(a, this.aa);
            let e = logBase(b, this.aa);
            let f = logBase(c, this.aa);
            return this.am(d, e, f);
        }
        return this.am(a, b, c);
    }
    am(a, b, c) {
        if (c < a || c > b) {
            return null;
        }
        let d = (c - a) / (b - a);
        let e = d * (this.brushes.count - 1);
        return this.v(e);
    }
    get_isReady() {
        return this.brushes != null && this.brushes.count > 0;
    }
    q(a, b, c, d) {
        switch (b) {
            case ValueBrushScale.$$p[1]:
                this.aa = typeGetValue(d);
                break;
            case ValueBrushScale.$$p[0]:
                this.w = d;
                break;
        }
        super.q(a, b, c, d);
    }
}
ValueBrushScale.$t = markType(ValueBrushScale, 'ValueBrushScale', BrushScale.$);
Type.dep(DependencyProperty, PropertyMetadata, ValueBrushScale, 'r', ['IsLogarithmic', [0, false], 'LogarithmBase', [1, 10], 'MaximumValue', [1, NaN], 'MinimumValue', [1, NaN]]);
