import { BalKeyboardSubject } from "./keyboard.subject";
export function ListenToKeyboard() {
    return function (target, _propertyKey, _descriptor) {
        const { connectedCallback, disconnectedCallback } = target;
        target.connectedCallback = function () {
            if (!this._balKeyboardSubject) {
                this._balKeyboardSubject = new BalKeyboardSubject();
                this._balKeyboardSubject.attach(this);
            }
            return connectedCallback && connectedCallback.call(this);
        };
        target.disconnectedCallback = function () {
            if (this._balKeyboardSubject) {
                this._balKeyboardSubject.detach();
                this._balKeyboardSubject = undefined;
            }
            return disconnectedCallback && disconnectedCallback.call(this);
        };
    };
}
