import { B as BalWindowResizeListener } from './breakpoints.subject-C32mP6rF.js';
import { a as SingleSubject } from './listener-CClDIhvK.js';
import { b as balBrowser } from './browser-B1u-Mq75.js';

class BalWindowResizeSubject extends SingleSubject {
    constructor() {
        super((observer, _data) => {
            observer.windowResizeListener();
        });
        this.listener = new BalWindowResizeListener();
    }
    attach(observer) {
        super.attach(observer);
        if (balBrowser.hasWindow) {
            this.listener.connect(window);
            this.listener.add(() => super.notify());
        }
    }
    detach() {
        super.detach();
        this.listener.disconnect();
    }
}
new BalWindowResizeSubject();

function ListenToWindowResize() {
    return function (target, _propertyKey, _descriptor) {
        const { connectedCallback, disconnectedCallback } = target;
        target.connectedCallback = function () {
            if (!this._balWindowResizeSubject) {
                this._balWindowResizeSubject = new BalWindowResizeSubject();
                this._balWindowResizeSubject.attach(this);
            }
            return connectedCallback && connectedCallback.call(this);
        };
        target.disconnectedCallback = function () {
            if (this._balWindowResizeSubject) {
                this._balWindowResizeSubject.detach();
                this._balWindowResizeSubject = undefined;
            }
            return disconnectedCallback && disconnectedCallback.call(this);
        };
    };
}

export { ListenToWindowResize as L };
