import{r as s,h as t,e as a}from"./index-DscFWUNz.js";import{a as l,b as n}from"./align-floating-elements-Bx4ukVlr-CFQB2kd1.js";import{a as r}from"./align-CyK0wp7d-DT9btF96.js";/*!
 * KoliBri - The accessible HTML-Standard
 */const d=(e,o)=>{r(e,"_popoverAlign",o)},_=class{constructor(e){s(this,e),this.state={_label:"",_popoverAlign:"bottom"},this.justClosed=!1,this.popoverOpen=!1,this._disabled=!1,this._hideLabel=!1,this._popoverAlign="bottom",this._tooltipAlign="top",this._type="button",this._variant="normal"}async hidePopover(){var e;(e=this.refPopover)===null||e===void 0||e.hidePopover()}handleBeforeToggle(e){var o;e.newState==="closed"?(this.justClosed=!0,setTimeout(()=>{this.justClosed=!1},10)):(this.refPopover&&(this.refPopover.style.visibility="hidden"),(o=this.refButton)===null||o===void 0||o.hideTooltip())}alignPopover(){this.refPopover&&this.refButton&&l({align:this.state._popoverAlign,floatingElement:this.refPopover,referenceElement:this.refButton})}handleToggle(e){this.popoverOpen=e.newState==="open",this.popoverOpen?this.refPopover&&this.refButton&&(this.cleanupAutoPositioning=n(this.refButton,this.refPopover,()=>{this.alignPopover()})):this.cleanupAutoPositioning&&(this.cleanupAutoPositioning(),this.cleanupAutoPositioning=void 0)}handleButtonClick(){var e;this.justClosed||(e=this.refPopover)===null||e===void 0||e.togglePopover()}componentDidRender(){var e,o;(e=this.refPopover)===null||e===void 0||e.addEventListener("toggle",this.handleToggle.bind(this)),(o=this.refPopover)===null||o===void 0||o.addEventListener("beforetoggle",this.handleBeforeToggle.bind(this))}disconnectedCallback(){var e,o,i;(e=this.refPopover)===null||e===void 0||e.removeEventListener("toggle",this.handleToggle.bind(this)),(o=this.refPopover)===null||o===void 0||o.removeEventListener("beforetoggle",this.handleBeforeToggle.bind(this)),(i=this.cleanupAutoPositioning)===null||i===void 0||i.call(this)}render(){return t("div",{key:"ed9bd3791a41c429effa8bba1fd4f835b26e7417",class:"kol-popover-button"},t(a,{key:"43ae7fc22399fd5d6aa526eb9c9402e877a71f3e",_accessKey:this._accessKey,"_aria-controls":"popover",_ariaControls:this._ariaControls,_ariaDescription:this._ariaDescription,_ariaExpanded:this.popoverOpen,_ariaHasPopup:"dialog",_ariaSelected:this._ariaSelected,_customClass:this._customClass,_disabled:this._disabled,_hideLabel:this._hideLabel,_icons:this._icons,_id:this._id,_label:this._label,_name:this._name,_on:this._on,_role:this._role,_shortKey:this._shortKey,_syncValueBySelector:this._syncValueBySelector,_tabIndex:this._tabIndex,_tooltipAlign:this._tooltipAlign,_type:this._type,_value:this._value,_buttonVariant:this._variant,"data-testid":"popover-button",class:"kol-popover-button__button",ref:e=>this.refButton=e,onClick:this.handleButtonClick.bind(this)},t("slot",{key:"4e312ac4d1c7e5695d78cd48feba9b3738a540a6",name:"expert",slot:"expert"})),t("div",{key:"c5dccff4d149aa043963ed1c81ba0f2391526a18",ref:e=>this.refPopover=e,"data-testid":"popover-content",popover:"auto",id:"popover",class:"kol-popover-button__popover"},t("slot",{key:"36f4ed8c4df5e3c80d6706ea3bdc440c77b987fc"})))}validatePopoverAlign(e){d(this,e)}componentWillLoad(){this.validatePopoverAlign(this._popoverAlign)}static get watchers(){return{_popoverAlign:["validatePopoverAlign"]}}};export{_ as kol_popover_button_wc};
//# sourceMappingURL=kol-popover-button-wc.entry-CViB3RdU.js.map
