/*
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 { 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
 */
export let DateEditorView = /*@__PURE__*/ (() => {
    class DateEditorView extends BaseEditorView {
        constructor(a, b, c) {
            super(a, c);
            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");
            let d = a.getSubRenderer(this.container);
            let e = a.createElement("div");
            d.append(e);
            let 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();
        }
        setFont(a) {
            this.q = a;
            if (this.p != null && this.q != null) {
                this.p.ad = this.q;
            }
        }
        attachEvents() {
            if (this.p != null) {
                let a = this.p;
                a.valueChanged = delegateCombine(a.valueChanged, runOn(this, this.onDatePickerValueChanged));
                let b = this.p;
                b.gotFocus = delegateCombine(b.gotFocus, runOn(this, this.onDatePickerGotFocus));
                let c = this.p;
                c.lostFocus = delegateCombine(c.lostFocus, runOn(this, this.onDatePickerLostFocus));
                let d = this.p;
                d.keyDown = delegateCombine(d.keyDown, runOn(this, this.onInputKeyDown));
                let e = this.p;
                e.changing = delegateCombine(e.changing, runOn(this, this.onInputChanging));
            }
        }
        detachEvents() {
            if (this.p != null) {
                let a = this.p;
                a.valueChanged = delegateRemove(a.valueChanged, runOn(this, this.onDatePickerValueChanged));
                let b = this.p;
                b.gotFocus = delegateRemove(b.gotFocus, runOn(this, this.onDatePickerGotFocus));
                let c = this.p;
                c.lostFocus = delegateRemove(c.lostFocus, runOn(this, this.onDatePickerLostFocus));
                let d = this.p;
                d.keyDown = delegateRemove(d.keyDown, runOn(this, this.onInputKeyDown));
                let e = this.p;
                e.changing = delegateRemove(e.changing, runOn(this, this.onInputChanging));
            }
        }
        onTargetChanged() {
            if (this.p != null) {
                this.r = true;
                this.focus();
                this.r = false;
            }
        }
        onEditStarted() {
            super.onEditStarted();
            if (!this.a.isEditRefocusDesired) {
                this.focus();
            }
        }
        onEditEnded() {
            super.onEditEnded();
            if (this.a.isEditRefocusDesired) {
                let a = this.e.rootWrapper.getNativeElement();
                if (a == document.activeElement || a.contains(document.activeElement)) {
                    this.focus();
                }
            }
        }
        l() {
            if (this.p != null) {
                this.p.focus();
                this.p.cw();
            }
        }
        s() {
            if (this.p != null) {
                this.p.b9();
            }
        }
        n(a, b, c) {
            super.n(a, b, c);
        }
        o() {
            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;
        }
        onDatePickerValueChanged(a, b) {
            this.x();
        }
        x() {
            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);
            }
        }
        onInputChanging(a, b) {
            this.j();
        }
        onDatePickerLostFocus(a, b) {
            this.i();
        }
        onDatePickerGotFocus(a, b) {
            this.h();
        }
    }
    DateEditorView.$t = /*@__PURE__*/ markType(DateEditorView, 'DateEditorView', BaseEditorView.$);
    return DateEditorView;
})();
//# sourceMappingURL=DateEditorView.js.map
