import{L as s,a as t}from"./p-ab217a42.js";import{b as e}from"./p-e680e7e4.js";import{j as i,r as h}from"./p-28b0e0a8.js";class r extends s{constructor(){super(...arguments),this.state=r.DefaultState,this.onMouseEnter=()=>{this.updateState({hovered:!0})},this.onMouseLeave=()=>{this.updateState({hovered:!1})},this.onPointerDown=()=>{this.updateState({pressed:!0})},this.onPointerUp=()=>{this.updateState({pressed:!1})}}connect(s){super.connect(s),i(this.el,"mouseenter",this.onMouseEnter,r.EventListenerOptions),i(this.el,"mouseleave",this.onMouseLeave,r.EventListenerOptions),i(this.el,"pointerdown",this.onPointerDown,r.EventListenerOptions),e.hasDocument&&i(document,"pointerup",this.onPointerUp,r.EventListenerOptions)}disconnect(){super.disconnect(),this.el&&(h(this.el,"mouseenter",this.onMouseEnter),h(this.el,"mouseleave",this.onMouseLeave),h(this.el,"pointerdown",this.onPointerDown),e.hasDocument&&h(document,"pointerup",this.onPointerUp))}updateState(s){this.state=Object.assign(Object.assign({},this.state),s),this.notify(this.state)}}r.EventListenerOptions={passive:!0},r.DefaultState={hovered:!1,pressed:!1};class n extends t{constructor(){super(((s,t)=>{t&&s.elementStateListener(t)})),this.listener=new r}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:e}=s;s.connectedCallback=function(){return this._balElementStateSubject||(this._balElementStateSubject=new n,this._balElementStateSubject.attach(this)),t&&t.call(this)},s.disconnectedCallback=function(){return this._balElementStateSubject&&(this._balElementStateSubject.detach(),this._balElementStateSubject=void 0),e&&e.call(this)}}}export{r as B,o as L}