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