import{r as t,h as s,H as i,g as o}from"./p-40eb06b7.js";import{c as n}from"./p-b415099e.js";import{c as e,f as a,s as d,o as h}from"./p-3777f34f.js";const r=class{constructor(s){t(this,s),this.show=!1,this.align="bottom",this.hover=!1,this.syncWidth=!1,this.offset=0}onAlignWatch(){this.updateDropdownContainer()}componentDidLoad(){this.container=this.el.querySelector(".dropdown-container"),this.updateDropdownContainer(),this.el.addEventListener("mouseenter",this.onMouseEnterOnContainer.bind(this)),this.el.addEventListener("mouseleave",this.onMouseLeaveOnContainer.bind(this))}disconectedCallback(){this.el&&(this.el.removeEventListener("mouseenter",this.onMouseEnterOnContainer),this.el.removeEventListener("mouseleave",this.onMouseLeaveOnContainer))}onMouseEnterOnContainer(){this.hover&&(this.show=!0)}onMouseLeaveOnContainer(){this.hover&&(this.show=!1)}updateDropdownContainer(){this.syncWidth?(this.container.style.maxWidth=`${this.el.offsetWidth}px`,this.container.style.width="100%"):(this.container.style.maxWidth="auto",this.container.style.width="auto"),setTimeout((()=>{e(this.el,this.container,{placement:this.align,middleware:[a(),d({padding:10}),h(this.offset)]}).then((({x:t,y:s})=>{this.container.style.left=`${t}px`,this.container.style.top=`${s}px`}))}),50)}async display(t){this.show=t}render(){return s(i,{key:"5f8255008c184d7631ccb4cd9551b116b5de5d41"},s("slot",{key:"e1ba19bc029636a57da7cc39b996d6bb074577d6"}),s("div",{key:"cf2519e2ac095151a8a32749dd1d3afd0feefb83",class:n("dropdown-container",{"dropdown-show":this.show,"dropdown-hover":this.hover})},s("slot",{key:"d272d43ac171bafd22fd83aba86bd693cbc87360",name:"dropdown"})))}get el(){return o(this)}static get watchers(){return{align:["onAlignWatch"],show:["onAlignWatch"]}}};r.style="x-dropdown{display:inherit;text-align:inherit}x-dropdown .dropdown-container{display:none;width:-webkit-max-content;width:-moz-max-content;width:max-content;top:0;left:0;position:absolute;z-index:10000}x-dropdown .dropdown-container.dropdown-show{display:block;-webkit-animation:0.3s fadeIn;animation:0.3s fadeIn}";export{r as x_dropdown}