import{r as a,P as n,h as o,d as h,H as r,m as d,t as p}from"./index-DJsSmExJ.js";import{b as c,a as u}from"./align-floating-elements-a7a489c8-DBcmCTP7.js";import{t as v,a as m}from"./tooltip-open-tracking-23a84b19-CZrYVTp5.js";import{v as f}from"./badge-text-553534d4-bSZ0jB2z.js";import{v as g}from"./align-f3101425-Ci8L7DKQ.js";import{v as E}from"./label-7d1ce375-BbZF87oK.js";/*!
 * KoliBri - The accessible HTML-Standard
 */const b=(e,t)=>{p(e,"_id",t)},s=new Set;function T(e){s.forEach(t=>{t.style.setProperty("z-index","999")}),s.add(e),e.style.setProperty("z-index","1000")}function y(e){if(s.delete(e),s.size>0){const t=Array.from(s).pop();t&&t.style.setProperty("z-index","1000")}}const F=class{constructor(e){a(this,e),this.hasFocusIn=!1,this.hasMouseIn=!1,this.showTooltip=()=>{if(this.previousSibling&&this.tooltipElement){T(this.tooltipElement),v(),this.tooltipElement.style.setProperty("display","block"),n().addEventListener("keyup",this.hideTooltipByEscape);const t=this.previousSibling,i=this.tooltipElement;this.cleanupAutoPositioning=c(t,i,()=>{this.alignTooltip()})}},this.hideTooltip=()=>{this.tooltipElement&&(y(this.tooltipElement),m(),this.tooltipElement.style.setProperty("display","none"),this.tooltipElement.style.setProperty("visibility","hidden"),this.cleanupAutoPositioning&&(this.cleanupAutoPositioning(),this.cleanupAutoPositioning=void 0)),n().removeEventListener("keyup",this.hideTooltipByEscape)},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,i,l=!1)=>{t&&this.removeListeners(t),i&&(l&&(this.previousSibling=i),this.addListeners(i))},this.catchTooltipElement=t=>{this.tooltipElement=t},this.catchArrowElement=t=>{this.arrowElement=t},this.showOrHideTooltip=()=>{clearTimeout(this.overFocusTimeout),this.overFocusTimeout=setTimeout(()=>{this.hasMouseIn||this.hasFocusIn?this.showTooltip():this.hideTooltip()},300)},this._badgeText=void 0,this._align="top",this._id=void 0,this._label=void 0,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})}handleMouseEnter(){this.hasMouseIn=!0,this.showOrHideTooltip()}handleMouseleave(){this.hasMouseIn=!1,this.showOrHideTooltip()}handleFocusIn(){this.hasFocusIn=!0,this.showOrHideTooltip()}handleFocusout(){this.hasFocusIn=!1,this.showOrHideTooltip()}render(){return o(r,{key:"c04cbc13912a59c5b863a27e4559392716829e00",class:"kol-tooltip-wc"},this.state._label!==""&&o("div",{key:"96ff93de26836c9e545c4590cd0770ad1f648be4",class:"tooltip-floating",ref:this.catchTooltipElement},o("div",{key:"ef6603e9458cad66fbc77d15b9b7c0e1102eae50",class:"tooltip-area tooltip-arrow",ref:this.catchArrowElement}),o(h,{key:"bef3edfd2c735a3997aef309fc19c4b789c7a254",class:"tooltip-area tooltip-content",id:this.state._id,_badgeText:this._badgeText,_label:this.state._label})))}validateBadgeText(e){f(this,e)}validateAlign(e){g(this,e)}validateId(e){b(this,e)}validateLabel(e){E(this,e,{required:!0})}componentWillLoad(){this.validateBadgeText(this._badgeText),this.validateAlign(this._align),this.validateId(this._id),this.validateLabel(this._label)}handleEventListeners(){var e;this.resyncListeners(this.previousSibling,(e=this.host)===null||e===void 0?void 0:e.previousElementSibling,!0),this.resyncListeners(this.tooltipElement,this.tooltipElement)}connectedCallback(){var e;this.previousSibling=(e=this.host)===null||e===void 0?void 0:e.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 d(this)}static get watchers(){return{_badgeText:["validateBadgeText"],_align:["validateAlign"],_id:["validateId"],_label:["validateLabel"]}}};export{F as kol_tooltip_wc};
//# sourceMappingURL=kol-tooltip-wc.entry-DdsPbqu9.js.map
