/*
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 { BaseEditorView } from "./BaseEditorView";
import { DatePicker } from "igniteui-webcomponents-inputs";
import { runOn, delegateCombine, delegateRemove, markType } from "igniteui-webcomponents-core";
import { dateMinValue } from "igniteui-webcomponents-core";
/**
 * @hidden
 */
var DateEditorView = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(DateEditorView, _super);
    function DateEditorView(a, b, c) {
        var _this = _super.call(this, a, c) || this;
        _this.p = null;
        _this.q = null;
        _this.r = false;
        _this.container = a.createElement("div");
        _this.container.setRawStyleProperty("width", "100%");
        _this.container.setRawStyleProperty("margin-top", "-10px");
        _this.container.setRawStyleProperty("height", "38px");
        var d = a.getSubRenderer(_this.container);
        var e = a.createElement("div");
        d.append(e);
        var f = a.createElement("div");
        d.append(f);
        _this.p = new DatePicker();
        _this.p.ap = false;
        _this.p.provideContainer(d);
        _this.p.b = b;
        _this.p.d = 3;
        if (_this.q != null) {
            _this.p.ad = _this.q;
        }
        _this.attachEvents();
        return _this;
    }
    DateEditorView.prototype.setFont = function (a) {
        this.q = a;
        if (this.p != null && this.q != null) {
            this.p.ad = this.q;
        }
    };
    DateEditorView.prototype.attachEvents = function () {
        if (this.p != null) {
            var a = this.p;
            a.valueChanged = delegateCombine(a.valueChanged, runOn(this, this.onDatePickerValueChanged));
            var b = this.p;
            b.gotFocus = delegateCombine(b.gotFocus, runOn(this, this.onDatePickerGotFocus));
            var c = this.p;
            c.lostFocus = delegateCombine(c.lostFocus, runOn(this, this.onDatePickerLostFocus));
            var d = this.p;
            d.keyDown = delegateCombine(d.keyDown, runOn(this, this.onInputKeyDown));
            var e = this.p;
            e.changing = delegateCombine(e.changing, runOn(this, this.onInputChanging));
        }
    };
    DateEditorView.prototype.detachEvents = function () {
        if (this.p != null) {
            var a = this.p;
            a.valueChanged = delegateRemove(a.valueChanged, runOn(this, this.onDatePickerValueChanged));
            var b = this.p;
            b.gotFocus = delegateRemove(b.gotFocus, runOn(this, this.onDatePickerGotFocus));
            var c = this.p;
            c.lostFocus = delegateRemove(c.lostFocus, runOn(this, this.onDatePickerLostFocus));
            var d = this.p;
            d.keyDown = delegateRemove(d.keyDown, runOn(this, this.onInputKeyDown));
            var e = this.p;
            e.changing = delegateRemove(e.changing, runOn(this, this.onInputChanging));
        }
    };
    DateEditorView.prototype.onTargetChanged = function () {
        if (this.p != null) {
            this.r = true;
            this.focus();
            this.r = false;
        }
    };
    DateEditorView.prototype.onEditStarted = function () {
        _super.prototype.onEditStarted.call(this);
        if (!this.a.isEditRefocusDesired) {
            this.focus();
        }
    };
    DateEditorView.prototype.onEditEnded = function () {
        _super.prototype.onEditEnded.call(this);
        if (this.a.isEditRefocusDesired) {
            var a = this.e.rootWrapper.getNativeElement();
            if (a == document.activeElement || a.contains(document.activeElement)) {
                this.focus();
            }
        }
    };
    DateEditorView.prototype.l = function () {
        if (this.p != null) {
            this.p.focus();
            this.p.cw();
        }
    };
    DateEditorView.prototype.s = function () {
        if (this.p != null) {
            this.p.b9();
        }
    };
    DateEditorView.prototype.n = function (a, b, c) {
        _super.prototype.n.call(this, a, b, c);
    };
    DateEditorView.prototype.o = function () {
        this.r = true;
        if (this.p != null) {
            if (this.value == null) {
                this.p.a0 = dateMinValue();
            }
            else {
                this.p.a0 = this.value;
            }
            this.l();
        }
        this.r = false;
    };
    DateEditorView.prototype.onDatePickerValueChanged = function (a, b) {
        this.x();
    };
    DateEditorView.prototype.x = function () {
        if (this.r) {
            return;
        }
        if (+(this.p.a0) != +(dateMinValue())) {
            this.k(this.p.a0, false);
        }
        else if (+(this.p.a0) == +(dateMinValue())) {
            this.k(null, false);
        }
        else {
            this.k(this.value, false);
        }
    };
    DateEditorView.prototype.onInputChanging = function (a, b) {
        this.j();
    };
    DateEditorView.prototype.onDatePickerLostFocus = function (a, b) {
        this.i();
    };
    DateEditorView.prototype.onDatePickerGotFocus = function (a, b) {
        this.h();
    };
    DateEditorView.$t = markType(DateEditorView, 'DateEditorView', BaseEditorView.$);
    return DateEditorView;
}(BaseEditorView));
export { DateEditorView };
//# sourceMappingURL=DateEditorView.js.map
