/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import * as tslib_1 from "tslib";
import { Base, markType } from "igniteui-react-core/ES5/type";
import { dateMaxValue, dateMinValue, dateAddYears, dateFromValues, dateAddMonths, dateFromTicks } from "igniteui-react-core/ES5/date";
var FinancialChartRangeSelectorViewModel = /** @class */ (function (_super) {
    tslib_1.__extends(FinancialChartRangeSelectorViewModel, _super);
    function FinancialChartRangeSelectorViewModel() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this._notifyChanged = null;
        _this._options = null;
        _this.n = dateMaxValue();
        _this.m = dateMinValue();
        _this._oneMonthChecked = false;
        _this._threeMonthsChecked = false;
        _this._sixMonthsChecked = false;
        _this._yearToDateChecked = false;
        _this._oneYearChecked = false;
        _this._allChecked = false;
        _this.l = dateMinValue();
        _this.k = dateMaxValue();
        _this._onRangeChanged = null;
        return _this;
    }
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "notifyChanged", {
        get: function () {
            return this._notifyChanged;
        },
        set: function (a) {
            this._notifyChanged = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "options", {
        get: function () {
            return this._options;
        },
        set: function (a) {
            this._options = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "selectionStart", {
        get: function () {
            return this.n;
        },
        set: function (a) {
            this.n = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "selectionEnd", {
        get: function () {
            return this.m;
        },
        set: function (a) {
            this.m = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "oneMonthChecked", {
        get: function () {
            return this._oneMonthChecked;
        },
        set: function (a) {
            this._oneMonthChecked = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "threeMonthsChecked", {
        get: function () {
            return this._threeMonthsChecked;
        },
        set: function (a) {
            this._threeMonthsChecked = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "sixMonthsChecked", {
        get: function () {
            return this._sixMonthsChecked;
        },
        set: function (a) {
            this._sixMonthsChecked = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "yearToDateChecked", {
        get: function () {
            return this._yearToDateChecked;
        },
        set: function (a) {
            this._yearToDateChecked = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "oneYearChecked", {
        get: function () {
            return this._oneYearChecked;
        },
        set: function (a) {
            this._oneYearChecked = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "allChecked", {
        get: function () {
            return this._allChecked;
        },
        set: function (a) {
            this._allChecked = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "rangeStart", {
        get: function () {
            return this.l;
        },
        set: function (a) {
            this.l = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "rangeEnd", {
        get: function () {
            return this.k;
        },
        set: function (a) {
            this.k = a;
        },
        enumerable: true,
        configurable: true
    });
    FinancialChartRangeSelectorViewModel.prototype.onPropertiesChanged = function () {
        var a = false;
        if (+(this.selectionEnd) == +(this.rangeEnd)) {
            if (this.allChecked != (+(this.selectionStart) == +(this.rangeStart))) {
                this.allChecked = +(this.selectionStart) == +(this.rangeStart);
                a = true;
            }
            if (this.oneYearChecked != (+(this.selectionStart) == +(this.oneYearFromEnd))) {
                this.oneYearChecked = +(this.selectionStart) == +(this.oneYearFromEnd);
                a = true;
            }
            if (this.yearToDateChecked != (+(this.selectionStart) == +(this.firstDayOfEndYear))) {
                this.yearToDateChecked = +(this.selectionStart) == +(this.firstDayOfEndYear);
                a = true;
            }
            if (this.sixMonthsChecked != (+(this.selectionStart) == +(this.sixMonthsFromEnd))) {
                this.sixMonthsChecked = +(this.selectionStart) == +(this.sixMonthsFromEnd);
                a = true;
            }
            if (this.threeMonthsChecked != (+(this.selectionStart) == +(this.threeMonthsFromEnd))) {
                this.threeMonthsChecked = +(this.selectionStart) == +(this.threeMonthsFromEnd);
                a = true;
            }
            if (this.oneMonthChecked != (+(this.selectionStart) == +(this.oneMonthFromEnd))) {
                this.oneMonthChecked = +(this.selectionStart) == +(this.oneMonthFromEnd);
                a = true;
            }
            if (a) {
                if (this.notifyChanged != null) {
                    this.notifyChanged();
                }
            }
        }
        return a;
    };
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "oneYearFromEnd", {
        get: function () {
            return dateAddYears(this.rangeEnd, -1);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "firstDayOfEndYear", {
        get: function () {
            return dateFromValues(this.rangeEnd.getFullYear(), 1, 1, 0, 0, 0, 0);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "sixMonthsFromEnd", {
        get: function () {
            return dateAddMonths(this.rangeEnd, -6);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "threeMonthsFromEnd", {
        get: function () {
            return dateAddMonths(this.rangeEnd, -3);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "oneMonthFromEnd", {
        get: function () {
            return dateAddMonths(this.rangeEnd, -1);
        },
        enumerable: true,
        configurable: true
    });
    FinancialChartRangeSelectorViewModel.prototype.changeSelection = function (a) {
        this.allChecked = false;
        this.oneMonthChecked = false;
        this.threeMonthsChecked = false;
        this.sixMonthsChecked = false;
        this.yearToDateChecked = false;
        this.oneYearChecked = false;
        if (a == "1m") {
            this.oneMonthChecked = true;
        }
        else if (a == "3m") {
            this.threeMonthsChecked = true;
        }
        else if (a == "6m") {
            this.sixMonthsChecked = true;
        }
        else if (a == "YTD") {
            this.yearToDateChecked = true;
        }
        else if (a == "1y") {
            this.oneYearChecked = true;
        }
        else if (a == "all") {
            this.allChecked = true;
        }
        this.onRadioButtonChanged();
    };
    FinancialChartRangeSelectorViewModel.prototype.onRadioButtonChanged = function () {
        var a = dateFromTicks(this.selectionStart.getTime());
        var b = dateFromTicks(this.selectionEnd.getTime());
        this.selectionEnd = this.rangeEnd;
        if (this.oneMonthChecked) {
            this.selectionStart = this.oneMonthFromEnd;
        }
        if (this.threeMonthsChecked) {
            this.selectionStart = this.threeMonthsFromEnd;
        }
        if (this.sixMonthsChecked) {
            this.selectionStart = this.sixMonthsFromEnd;
        }
        if (this.yearToDateChecked) {
            this.selectionStart = this.firstDayOfEndYear;
        }
        if (this.oneYearChecked) {
            this.selectionStart = this.oneYearFromEnd;
        }
        if (this.allChecked) {
            this.selectionStart = this.rangeStart;
        }
        if (+(this.selectionStart) != +a || +(this.selectionEnd) != +b) {
            this.onRangeChanged();
        }
    };
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "onRangeChanged", {
        get: function () {
            return this._onRangeChanged;
        },
        set: function (a) {
            this._onRangeChanged = a;
        },
        enumerable: true,
        configurable: true
    });
    FinancialChartRangeSelectorViewModel.$t = markType(FinancialChartRangeSelectorViewModel, 'FinancialChartRangeSelectorViewModel');
    return FinancialChartRangeSelectorViewModel;
}(Base));
export { FinancialChartRangeSelectorViewModel };
