/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import * as tslib_1 from "tslib";
import { LegendBase } from "./LegendBase";
import { IChartScaleLegend_$type } from "igniteui-react-core";
import { TextBlock } from "igniteui-react-core";
import { LegendBaseView } from "./LegendBaseView";
import { typeCast, markType, runOn, Point_$type } from "igniteui-react-core";
import { Color } from "igniteui-react-core";
import { Brush } from "igniteui-react-core";
import { ColorUtil } from "igniteui-react-core";
import { Shape } from "igniteui-react-core";
import { GradientData } from "./GradientData";
import { Size } from "igniteui-react-core";
import { Polygon } from "igniteui-react-core";
import { GradientStopData } from "./GradientStopData";
import { IInternalLegendOwner_$type } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
/**
 * @hidden
 */
var ScaleLegend = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(ScaleLegend, _super);
    function ScaleLegend() {
        var _this = _super.call(this) || this;
        _this.bd = null;
        _this.bf = 0;
        _this.be = 0;
        _this.bb = null;
        _this.ab = ScaleLegend.$;
        return _this;
    }
    ScaleLegend.prototype.aj = function () {
        return new ScaleLegendView(this);
    };
    ScaleLegend.prototype.a8 = function (a) {
        _super.prototype.a8.call(this, a);
        this.bd = a;
    };
    Object.defineProperty(ScaleLegend.prototype, "legendScaleElement", {
        get: function () {
            return this.bd.ba;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScaleLegend.prototype, "minText", {
        get: function () {
            return this.bd.a6;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScaleLegend.prototype, "maxText", {
        get: function () {
            return this.bd.a5;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScaleLegend.prototype, "bc", {
        get: function () {
            return this.bb;
        },
        set: function (a) {
            this.bb = a;
        },
        enumerable: true,
        configurable: true
    });
    ScaleLegend.prototype.bi = function () {
        this.bd.a2();
    };
    ScaleLegend.prototype.restoreOriginalState = function () {
        this.bi();
    };
    ScaleLegend.prototype.bl = function (a) {
        if (a == null) {
            return this.bd.a9();
        }
        return ColorUtil.t(a);
    };
    ScaleLegend.prototype.bg = function (a) {
        this.bc = a;
        this.bh();
    };
    ScaleLegend.prototype.initializeLegend = function (a) {
        this.bg(a);
    };
    ScaleLegend.prototype.get_isScale = function () {
        return true;
    };
    ScaleLegend.prototype.bh = function () {
        var _this = this;
        if (this.legendScaleElement == null || this.bc == null || !this.bc.legendReady) {
            return;
        }
        if (this.bc == null || !this.bc.isAttachedTo(this)) {
            return;
        }
        var a = false;
        var b = typeCast(Shape.$, this.legendScaleElement);
        if (b != null) {
            var c_1 = this.bd.aw();
            if (!this.bc.forScaleColors(function (d, e) { return _this.bd.ay(c_1, _this.bl(d), e); })) {
                a = true;
            }
            this.bd.a3(b, a, c_1);
        }
        if (this.minText != null) {
            this.minText.ak = this.bc.minScaleText;
        }
        if (this.maxText != null) {
            this.maxText.ak = this.bc.maxScaleText;
        }
    };
    ScaleLegend.$t = markType(ScaleLegend, 'ScaleLegend', LegendBase.$, [IChartScaleLegend_$type]);
    return ScaleLegend;
}(LegendBase));
export { ScaleLegend };
/**
 * @hidden
 */
var ScaleLegendView = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(ScaleLegendView, _super);
    function ScaleLegendView(a) {
        var _this = _super.call(this, a) || this;
        _this.ap = null;
        _this.ba = null;
        _this.a6 = null;
        _this.a5 = null;
        _this.ao = null;
        _this.aq = null;
        _this.bb = new Size();
        _this.ar = false;
        _this.as = 0;
        _this.a8 = null;
        _this.a7 = null;
        _this.ap = a;
        _this.a6 = new TextBlock();
        _this.a5 = new TextBlock();
        _this.ba = new Polygon();
        return _this;
    }
    ScaleLegendView.prototype.a2 = function () {
    };
    ScaleLegendView.prototype.z = function () {
    };
    ScaleLegendView.prototype.a9 = function () {
        return Color.u(0, 0, 0, 0);
    };
    ScaleLegendView.prototype.aw = function () {
        return new GradientData();
    };
    ScaleLegendView.prototype.ay = function (a, b, c) {
        var d = a;
        d.a.add(((function () {
            var $ret = new GradientStopData();
            $ret.b = ((function () {
                var $ret = new Brush();
                $ret.color = b;
                return $ret;
            })());
            $ret.a = c;
            return $ret;
        })()));
    };
    ScaleLegendView.prototype.a3 = function (a, b, c) {
        if (b) {
            this.a7 = this.ap.bc.actualMarkerBrush;
            this.ao = null;
        }
        else {
            this.a7 = null;
            this.ao = c;
            this.ao.b();
        }
        this.az();
    };
    ScaleLegendView.prototype.ai = function (a) {
        _super.prototype.ai.call(this, a);
        this.aq = this.c.b(a);
        this.bb = this.c.ab();
        this.az();
    };
    ScaleLegendView.prototype.az = function () {
        if (!this.ar) {
            this.ar = true;
            if (this.c.g != null) {
                this.c.g.setTimeout(runOn(this, this.a4), 0);
            }
            else {
                window.setTimeout(runOn(this, this.a4), 0);
            }
        }
    };
    ScaleLegendView.prototype.a4 = function () {
        if (this.ar) {
            this.ar = false;
            this.a1();
        }
    };
    ScaleLegendView.prototype.a1 = function () {
        if (this.aq == null) {
            return;
        }
        this.a0();
    };
    ScaleLegendView.prototype.au = function (a) {
        var b = typeCast(TextBlock.$, a);
        if (b != null && b.ak != null) {
            return this.aq.e(b) + 0;
        }
        return 0;
    };
    ScaleLegendView.prototype.at = function (a) {
        return this.as + 0;
    };
    ScaleLegendView.prototype.a0 = function () {
        if (this.ap.bc == null || this.ap.bc.container == null || (this.ao == null && this.a7 == null)) {
            return;
        }
        if (this.aq.d) {
            var a = typeCast(IInternalLegendOwner_$type, this.ap.bc.container);
            this.aq.ac(a.getFontInfo());
            this.as = a.getFontHeight();
            this.a8 = a.getFontBrush();
            var b = this.au(this.a6);
            var c = this.au(this.a5);
            var d = Math.max(b, c) + 4;
            if (d >= this.bb.width) {
                d = 0;
            }
            var e = this.bb.width - d;
            var f = 2;
            var g = 2;
            e = e - 4;
            var h = this.bb.height - 4;
            var i = f + e + 4;
            var j = g;
            var k = h;
            var l = { $type: Point_$type, x: f + (3 / 5) * e, y: g };
            var m = { $type: Point_$type, x: f + (5 / 5) * e, y: g };
            var n = { $type: Point_$type, x: f + (5 / 5) * e, y: h };
            var o = { $type: Point_$type, x: f, y: h };
            var p = this.ba;
            p.ak.clear();
            p.ak.add(l);
            p.ak.add(m);
            p.ak.add(n);
            p.ak.add(o);
            this.a6.n = i;
            this.a6.o = j;
            this.a6.am = this.a8;
            this.a5.n = i;
            this.a5.o = j + k - (this.at(this.a6));
            this.a5.am = this.a8;
            this.aq.k(0, 0, this.bb.width, this.bb.height);
            if (this.ao == null && this.a7 != null) {
                p._fill = this.a7;
                this.aq.t(p);
            }
            else {
                this.c.y(this.aq, p, this.ao, new Rect(0, g, f, e, h));
            }
            if (d > 0) {
                this.aq.w(this.a6);
                this.aq.w(this.a5);
            }
        }
    };
    ScaleLegendView.prototype.al = function () {
        _super.prototype.al.call(this);
    };
    ScaleLegendView.$t = markType(ScaleLegendView, 'ScaleLegendView', LegendBaseView.$);
    return ScaleLegendView;
}(LegendBaseView));
export { ScaleLegendView };
//# sourceMappingURL=ScaleLegend_combined.js.map
