import{k as s,r as t}from"./p-Ba5qjFjW.js";import{L as i,a as e}from"./p-C20cwFWy.js";import{b as h}from"./p-B1u-Mq75.js";class n extends i{constructor(){super(...arguments),this.debouncedNotify=s((s=>this.notify(s)),42)}connect(s){var t;super.connect(s),"undefined"!=typeof ResizeObserver&&(void 0!==this.resizeObserver&&(null===(t=this.resizeObserver)||void 0===t||t.disconnect(),this.resizeObserver=void 0),this.resizeObserver=new ResizeObserver((s=>{h.hasWindow&&window.requestAnimationFrame((()=>{if(!Array.isArray(s)||!s.length)return;const t=s[0];if(void 0===this.lastWidth&&void 0===this.lastHeight)this.lastWidth=t.contentRect.width,this.lastHeight=t.contentRect.height;else{const s=this.lastWidth!==t.contentRect.width,i=this.lastHeight!==t.contentRect.height;(s||i)&&(this.debouncedNotify({width:s,height:i}),this.lastWidth=t.contentRect.width,this.lastHeight=t.contentRect.height)}}))})),this.resizeObserver.observe(s))}disconnect(){var s;super.disconnect(),null===(s=this.resizeObserver)||void 0===s||s.disconnect(),this.resizeObserver=void 0}}class r extends e{constructor(){super(((s,i)=>{t((()=>s.resizeListener(i)))})),this.listener=new n}attach(s){super.attach(s),this.listener.connect(s.el),this.listener.add((s=>super.notify(s)))}detach(){super.detach(),this.listener.disconnect()}}function o(){return function(s){const{connectedCallback:t,disconnectedCallback:i}=s;s.connectedCallback=function(){return this._balResizeSubject||(this._balResizeSubject=new r,this._balResizeSubject.attach(this)),t&&t.call(this)},s.disconnectedCallback=function(){return this._balResizeSubject&&(this._balResizeSubject.detach(),this._balResizeSubject=void 0),i&&i.call(this)}}}export{o as L}