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