import { BalAnimationSubject } from "./animation.subject";
export function ListenToAnimation() {
    return function (target, _propertyKey, _descriptor) {
        const { connectedCallback, componentDidLoad, disconnectedCallback } = target;
        target.connectedCallback = function () {
            if (!this._balAnimationSubject) {
                this._balAnimationSubject = new BalAnimationSubject();
            }
            return connectedCallback && connectedCallback.call(this);
        };
        target.componentDidLoad = function () {
            this._balAnimationSubject.attach(this);
            return componentDidLoad && componentDidLoad.call(this);
        };
        target.disconnectedCallback = function () {
            if (this._balAnimationSubject) {
                this._balAnimationSubject.detach();
                this._balAnimationSubject = undefined;
            }
            return disconnectedCallback && disconnectedCallback.call(this);
        };
    };
}
