import { closeAutocomplete } from "../extensions/behavior/Autocomplete/index.js";
export 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() {
        closeAutocomplete(this.#view);
    }
    cancelTimer() {
        if (this.#timer !== undefined) {
            clearTimeout(this.#timer);
            this.#timer = undefined;
        }
    }
}
//# sourceMappingURL=autocomplete-popup.js.map
