import{r,O as l,h as s,H as d,g as p,n as a}from"./index-DscFWUNz.js";import{b as c,a as u}from"./align-floating-elements-Bx4ukVlr-CFQB2kd1.js";import{v as m}from"./align-CyK0wp7d-DT9btF96.js";import{v}from"./label-CdtNxOKu-DuSxxbJz.js";import"./Alert-R2nEqfd2-D16I8H-s.js";import{K as E}from"./Span-43sGxXr7-LxLqNQk3.js";import"./i18n-CdSCDnmA-Bln0Fy0B.js";import"./Heading-DT8fK42U-BBz359Il.js";import"./markdown-DL-PkOqb-zRCMnbWa.js";import"./isObject-DvSELytj-B0RigBxT.js";import"./clsx-eK3rPvPS-BT_IL7Fz.js";import"./Icon-oHNRs_Az-BbbmR1N5.js";import"./reuse-CX4AQDkS-Cyh-fyjG.js";import"./InternalUnderlinedBadgeText-dfa2g8TL-B5v3VETx.js";/*!
 * KoliBri - The accessible HTML-Standard
 */const b=(i,t)=>{a(i,"_badgeText",t)},g=(i,t)=>{a(i,"_id",t)},o=new Set;function T(i){o.forEach(t=>{t.style.setProperty("z-index","999")}),o.add(i),i.style.setProperty("z-index","1000")}function f(i){if(o.delete(i),o.size>0){const t=Array.from(o).pop();t&&t.style.setProperty("z-index","1000")}}const n=300,M=class{constructor(i){r(this,i),this.showTooltip=()=>{if(this.previousSibling&&this.tooltipElement){T(this.tooltipElement),this.tooltipElement.style.setProperty("display","block"),l().addEventListener("keyup",this.hideTooltipByEscape);const t=this.previousSibling,e=this.tooltipElement;this.cleanupAutoPositioning=c(t,e,()=>{this.alignTooltip()})}},this.showTooltipWithDelay=()=>{clearTimeout(this.hideTooltipTimeout),clearTimeout(this.showTooltipTimeout),this.showTooltipTimeout=setTimeout(()=>{this.showTooltip()},n)},this.hideTooltipWithDelay=()=>{clearTimeout(this.hideTooltipTimeout),this.hideTooltipTimeout=setTimeout(()=>{this.hideTooltip()},n)},this.hideTooltipByEscape=t=>{t.key==="Escape"&&this.hideTooltip()},this.addListeners=t=>{t.addEventListener("mouseenter",this.handleMouseEnter.bind(this)),t.addEventListener("mouseleave",this.handleMouseleave.bind(this)),t.addEventListener("focusin",this.handleFocusIn.bind(this)),t.addEventListener("focusout",this.handleFocusout.bind(this))},this.removeListeners=t=>{t.removeEventListener("mouseenter",this.handleMouseEnter.bind(this)),t.removeEventListener("mouseleave",this.handleMouseleave.bind(this)),t.removeEventListener("focusin",this.handleFocusIn.bind(this)),t.removeEventListener("focusout",this.handleFocusout.bind(this))},this.resyncListeners=(t,e,h=!1)=>{t&&this.removeListeners(t),e&&(h&&(this.previousSibling=e),this.addListeners(e))},this.catchTooltipElement=t=>{this.tooltipElement=t},this.catchArrowElement=t=>{this.arrowElement=t},this._align="top",this.state={_align:"top",_label:""}}async alignTooltip(){this.tooltipElement&&this.previousSibling&&await u({align:this._align,referenceElement:this.previousSibling,arrowElement:this.arrowElement,floatingElement:this.tooltipElement})}async hideTooltip(){clearTimeout(this.showTooltipTimeout),this.tooltipElement&&(f(this.tooltipElement),this.tooltipElement.style.setProperty("display","none"),this.tooltipElement.style.setProperty("visibility","hidden"),this.cleanupAutoPositioning&&(this.cleanupAutoPositioning(),this.cleanupAutoPositioning=void 0)),l().removeEventListener("keyup",this.hideTooltipByEscape)}handleMouseEnter(){this.showTooltipWithDelay()}handleMouseleave(){this.hideTooltipWithDelay()}handleFocusIn(){this.showTooltipWithDelay()}handleFocusout(){this.hideTooltipWithDelay()}render(){return s(d,{key:"60be1bd258bc5ae2b0ecce9374607d11476071b1",class:"kol-tooltip"},this.state._label!==""&&s("div",{key:"2af044756ca7d87c5b789181da84556a517c0ee4",class:"kol-tooltip__floating",ref:this.catchTooltipElement},s("div",{key:"057fc2de5c87f0f82e9477568992048bf3918e77",class:"kol-tooltip__arrow",ref:this.catchArrowElement}),s(E,{key:"1ba456fb877c04c0dc1e93431f90db07f2e90b47",class:"kol-tooltip__content",id:this.state._id,badgeText:this._badgeText,label:this.state._label})))}validateBadgeText(i){b(this,i)}validateAlign(i){m(this,i)}validateId(i){g(this,i)}validateLabel(i){v(this,i,{required:!0})}componentWillLoad(){this.validateBadgeText(this._badgeText),this.validateAlign(this._align),this.validateId(this._id),this.validateLabel(this._label)}handleEventListeners(){var i;this.resyncListeners(this.previousSibling,(i=this.host)===null||i===void 0?void 0:i.previousElementSibling,!0),this.resyncListeners(this.tooltipElement,this.tooltipElement)}connectedCallback(){var i;this.previousSibling=(i=this.host)===null||i===void 0?void 0:i.previousElementSibling}componentDidRender(){this.handleEventListeners()}disconnectedCallback(){this.previousSibling&&(this.removeListeners(this.previousSibling),this.previousSibling=void 0),this.tooltipElement&&this.removeListeners(this.tooltipElement),this.cleanupAutoPositioning&&this.cleanupAutoPositioning()}get host(){return p(this)}static get watchers(){return{_badgeText:["validateBadgeText"],_align:["validateAlign"],_id:["validateId"],_label:["validateLabel"]}}};export{M as kol_tooltip_wc};
//# sourceMappingURL=kol-tooltip-wc.entry-W1G2F19J.js.map
