"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutocompletePopupCloser = void 0;
const Autocomplete_1 = require("../extensions/behavior/Autocomplete/index.js");
class AutocompletePopupCloser {
    #view;
    #timer;
    constructor(view) {
        this.#view = view;
    }
    popupOpenChangeHandler = (_open, _event, reason) => {
        if (reason === 'escape-key') {
            this.closeAutocomplete();
            return;
        }
        if (!this.#view.hasFocus()) {
            this.#timer = setTimeout(() => {
                this.#timer = undefined;
                if (!this.#view.hasFocus()) {
                    this.closeAutocomplete();
                }
            }, 20);
        }
    };
    closeAutocomplete() {
        (0, Autocomplete_1.closeAutocomplete)(this.#view);
    }
    cancelTimer() {
        if (this.#timer !== undefined) {
            clearTimeout(this.#timer);
            this.#timer = undefined;
        }
    }
}
exports.AutocompletePopupCloser = AutocompletePopupCloser;
//# sourceMappingURL=autocomplete-popup.js.map
