import{d as t,a as s,k as i}from"./p-Ba5qjFjW.js";import{L as n,a as e}from"./p-C20cwFWy.js";class o extends n{constructor(){super(...arguments),this.waitAfterFramePrint=!1,this.intersectionObserver=void 0,this.intersectionCallback=t=>{t.some((t=>t.isIntersecting))&&this.notify()}}async connect(i){super.connect(i),"undefined"!=typeof IntersectionObserver&&(this.waitAfterFramePrint&&(await t(i),await s()),this.destroyMutationObserver(),this.intersectionObserver=new IntersectionObserver(this.intersectionCallback,{root:null,threshold:.5}),this.intersectionObserver.observe(i))}disconnect(){super.disconnect(),this.destroyMutationObserver()}destroyMutationObserver(){void 0!==this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=void 0)}}class r extends e{constructor(){super((t=>{t.visibilityListener()})),this.debouncedNotify=i((()=>this.notify()),50),this.listener=new o}attach(t){var s,i;super.attach(t),null===(s=this.listener)||void 0===s||s.connect(t.el),null===(i=this.listener)||void 0===i||i.add((()=>this.debouncedNotify()))}detach(){var t;super.detach(),null===(t=this.listener)||void 0===t||t.disconnect()}}function h(){return function(t){const{connectedCallback:s,componentDidLoad:i,disconnectedCallback:n}=t;t.connectedCallback=function(){return this._balVisibilitySubject||(this._balVisibilitySubject=new r),s&&s.call(this)},t.componentDidLoad=function(){return this._balVisibilitySubject.attach(this),i&&i.call(this)},t.disconnectedCallback=function(){return this._balVisibilitySubject&&(this._balVisibilitySubject.detach(),this._balVisibilitySubject=void 0),n&&n.call(this)}}}export{h as L}