import{r,O as l,h as s,H as d,g as p,n as a}from"./index-BvWOSbaR.js";import{b as c,a as m}from"./align-floating-elements-Bx4ukVlr-BjpcfWth.js";import{v as u}from"./align-CyK0wp7d-B1c2PRsI.js";import{v}from"./label-CdtNxOKu-BgP05vXh.js";import"./Alert-yh8R3coC-BCYFPt1y.js";import{K as E}from"./Span-5ZR0JDnP-DY-b2WcQ.js";import"./i18n-CdSCDnmA-CsM0aySV.js";import{t as g,a as T}from"./tooltip-open-tracking-rBbBgPWP-CZrYVTp5.js";import"./tslib.es6-CxX45GIN-BAJoBDh7.js";import"./markdown-DL-PkOqb-CqqGVzr6.js";import"./isObject-DvSELytj-B0RigBxT.js";import"./clsx-eK3rPvPS-BT_IL7Fz.js";import"./Heading-KhwFHPZb-CVH-FD5x.js";import"./Icon-BsRmEtCa-1x6tgY8w.js";import"./reuse-CX4AQDkS-Cyh-fyjG.js";import"./InternalUnderlinedBadgeText-BnPUgbKl-BvtrJtYz.js";/*!
 * KoliBri - The accessible HTML-Standard
 */const b=(i,t)=>{a(i,"_badgeText",t)},f=(i,t)=>{a(i,"_id",t)},o=new Set;function y(i){o.forEach(t=>{t.style.setProperty("z-index","999")}),o.add(i),i.style.setProperty("z-index","1000")}function L(i){if(o.delete(i),o.size>0){const t=Array.from(o).pop();t&&t.style.setProperty("z-index","1000")}}const n=300,K=class{constructor(i){r(this,i),this.showTooltip=()=>{if(this.previousSibling&&this.tooltipElement){y(this.tooltipElement),g(),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 m({align:this._align,referenceElement:this.previousSibling,arrowElement:this.arrowElement,floatingElement:this.tooltipElement})}async hideTooltip(){clearTimeout(this.showTooltipTimeout),this.tooltipElement&&(L(this.tooltipElement),T(),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:"f6e31c6aa5dc271ada1f4096427b58a9a5d0b103",class:"kol-tooltip"},this.state._label!==""&&s("div",{key:"96c552106c2451123f77cc3214519e992f652056",class:"kol-tooltip__floating",ref:this.catchTooltipElement},s("div",{key:"d3e834e3c18fb563b4a521e476e221e8eb1c3964",class:"kol-tooltip__arrow",ref:this.catchArrowElement}),s(E,{key:"18b65ec1410d49445016aa3ca0373a113b3e9510",class:"kol-tooltip__content",id:this.state._id,badgeText:this._badgeText,label:this.state._label})))}validateBadgeText(i){b(this,i)}validateAlign(i){u(this,i)}validateId(i){f(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{K as kol_tooltip_wc};
//# sourceMappingURL=kol-tooltip-wc.entry-DEDz5_8G.js.map
