import{r as t,c as o,h as i,H as s,g as e}from"./p-93b809e8.js";import{g as n,p as h}from"./p-feb3bd38.js";const a=class{constructor(i){t(this,i),this.bdsToggle=o(this,"bdsToggle",7),this.onCloseSubMenu=()=>{this.stateSubMenu="close"},this.refDropElement=t=>{this.dropElement=t},this.onClickCloseButtom=()=>{this.open=!1},this.openSubmenu=()=>{"hover"===this.activeMode&&(this.zIndex=1),this.openSubMenu=!0},this.closeSubmenu=()=>{"hover"===this.activeMode&&(this.zIndex=0),this.openSubMenu=!1},this.centerDropElement=t=>{const o=t.split("-");"left"!=o[0]&&"right"!=o[0]||"center"!=o[1]||(this.dropElement.style.top=`calc(50% - ${this.dropElement.offsetHeight/2}px)`)},this.intoView=null,this.openSubMenu=!1,this.stateSubMenu="close",this.zIndex=0,this.delay=null,this.activeMode="click",this.open=!1,this.position="auto",this.dataTest=null}componentWillLoad(){this.activatorElement=this.hostElement.querySelector('[slot="dropdown-activator"]').children[0],this.intoView=n(this.hostElement),"hover"==this.activeMode?(this.activatorElement.addEventListener("mouseover",(()=>this.openSubmenu())),this.activatorElement.addEventListener("click",(()=>this.openSubmenu())),this.activatorElement.addEventListener("mouseout",(()=>this.closeSubmenu()))):this.activatorElement.addEventListener("click",(()=>this.toggle()))}componentDidLoad(){"auto"!=this.position?(this.centerDropElement(this.position),this.setDefaultPlacement(this.position)):this.validatePositionDrop()}setDefaultPlacement(t){this.dropElement.classList.add(`dropdown__basic__${t}`)}validatePositionDrop(){const t=h({actionElement:this.hostElement,changedElement:this.dropElement,intoView:this.intoView});this.dropElement.classList.add(`dropdown__basic__${t.y}-${t.x}`)}isOpenChanged(t){this.bdsToggle.emit({value:t}),t&&("auto"!=this.position?this.setDefaultPlacement(this.position):this.validatePositionDrop())}isPositionChanged(){this.setDefaultPlacement(this.position)}async toggle(){this.open=!this.open}async setOpen(){this.open=!0}async setClose(){this.open=!1}openSubMenuChanged(t){0==t&&(this.stateSubMenu="pending",this.delay=setTimeout(this.onCloseSubMenu,1e3)),1==t&&(clearTimeout(this.delay),this.delay=null,this.stateSubMenu="open")}stateSubMenuChanged(t){switch(t){case"open":case"pending":this.open=!0;break;case"close":this.open=!1}}render(){const t={zIndex:`${this.zIndex}`};return i(s,null,i("slot",{name:"dropdown-activator"}),i("div",{ref:t=>this.refDropElement(t),class:{dropdown:!0,dropdown__open:this.open},"data-test":this.dataTest,onMouseOver:()=>this.openSubmenu(),onMouseOut:()=>this.closeSubmenu()},i("div",{class:"content",style:t},i("slot",{name:"dropdown-content"}))),"hover"!==this.activeMode&&this.open&&i("div",{class:{outzone:!0},onClick:()=>this.onClickCloseButtom()}))}get hostElement(){return e(this)}static get watchers(){return{open:["isOpenChanged"],position:["isPositionChanged"],openSubMenu:["openSubMenuChanged"],stateSubMenu:["stateSubMenuChanged"]}}};a.style=':host{position:relative;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host(.is_child_drop){display:block;width:100%}.dropdown{position:absolute;pointer-events:none;padding:2px;background-color:var(--color-surface-0, #ffffff);border-radius:8px;-webkit-box-shadow:0px 6px 16px -4px var(--color-shadow-1, rgba(0, 0, 0, 0.16));box-shadow:0px 6px 16px -4px var(--color-shadow-1, rgba(0, 0, 0, 0.16));min-width:240px;width:-webkit-max-content;width:-moz-max-content;width:max-content;opacity:0;-webkit-transition:opacity 0.5s;-moz-transition:opacity 0.5s;transition:opacity 0.5s;z-index:90000}.dropdown__open{pointer-events:auto;opacity:1}.dropdown__basic__top-center{bottom:calc(100% + 16px);left:calc(50% - 122px)}.dropdown__basic__top-left{bottom:calc(100% + 16px);left:0}.dropdown__basic__top-right{bottom:calc(100% + 16px);right:0}.dropdown__basic__bottom-center{top:calc(100% + 16px);left:calc(50% - 122px)}.dropdown__basic__bottom-right{top:calc(100% + 16px);right:0}.dropdown__basic__bottom-left{top:calc(100% + 16px);left:0}.dropdown__basic__right-center{right:calc(100% + 8px)}.dropdown__basic__right-top{right:calc(100% + 8px);top:0}.dropdown__basic__right-bottom{right:calc(100% + 8px);bottom:0}.dropdown__basic__left-center{left:calc(100% + 8px)}.dropdown__basic__left-top{left:calc(100% + 8px);top:0}.dropdown__basic__left-bottom{left:calc(100% + 8px);bottom:0}.dropdown:after{content:"";position:absolute;inset:0;border-radius:8px;-webkit-box-shadow:var(--color-surface-0, #ffffff) 0px 0px 0px 2px inset;box-shadow:var(--color-surface-0, #ffffff) 0px 0px 0px 2px inset;pointer-events:none}.outzone{position:fixed;top:0;left:0;width:100%;height:100vh;z-index:80000}';export{a as bds_dropdown}