"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("fourdom"),n=require("@floating-ui/dom"),h=o=>{const i={content:"",appendTo:document.body,effect:"dark",placement:"top",arrowWidth:8,showArrow:!0};return typeof o=="string"||!o?i:Object.assign(i,o)},E=(o,i,t)=>{const r=h(t==null?void 0:t.bindingValue),e=t==null?void 0:t.arrowElement,l=r.showArrow&&e,a=[n.offset(6),n.flip(),n.shift({padding:5}),n.inline()];l&&a.push(n.arrow({element:e}));const d=r.placement;n.computePosition(o,i,{placement:d,middleware:a}).then(({x:u,y:p,placement:c,middlewareData:m})=>{var f,w;if(Object.assign(i.style,{left:`${u}px`,top:`${p}px`}),l){const _=(f=m.arrow)==null?void 0:f.x,b=(w=m.arrow)==null?void 0:w.y;Object.assign(e.style,{left:_!=null?`${_}px`:"",top:b!=null?`${b}px`:"",right:"",bottom:""});const s={top:"bottom",right:"left",bottom:"top",left:"right"}[c.split("-")[0]];s&&(Object.assign(e.style,{[s]:`-${r.arrowWidth/2}px`}),s==="bottom"?Object.assign(e.style,{"border-bottom":"var(--autotooltip-theme-border--light)","border-right":"var(--autotooltip-theme-border--light)"}):s==="top"?Object.assign(e.style,{"border-left":"var(--autotooltip-theme-border--light)","border-top":"var(--autotooltip-theme-border--light)"}):s==="left"?Object.assign(e.style,{"border-left":"var(--autotooltip-theme-border--light)","border-bottom":"var(--autotooltip-theme-border--light)"}):s==="right"&&Object.assign(e.style,{"border-top":"var(--autotooltip-theme-border--light)","border-right":"var(--autotooltip-theme-border--light)"}))}})},T=(o,i,t)=>{i.style.display="block",E(o,i,t)};function v(o){o.style.display=""}const L=(o,i)=>{const t=h(i),r=`is-${t.effect}`,e=document.createElement("div");return y.css(e,{"--autotooltip-arrow--width":`${t.arrowWidth}px`}),e.classList.add("autotooltip-wrapper"),e.classList.add(r),e.innerHTML=`${o}
`,e};function O(o){return o.scrollWidth>o.offsetWidth}const g=o=>{o._showTooltipListener&&o.removeEventListener("mouseenter",o._showTooltipListener),o._hideTooltipListener&&o.removeEventListener("mouseleave",o._hideTooltipListener),o._cleanup&&o._cleanup()},x={bind(o,i){o._init=(t,r)=>{g(t),t._showTooltipListener=()=>{var c;const e=h(r.value),l=typeof e.appendTo=="string"?document.querySelector(e.appendTo)||document.body:e.appendTo,a=typeof r.value=="string"?r.value:(c=r.value)==null?void 0:c.content,d=a||t.innerText,u=!!a||O(t);t!=null&&t._tooltipEl&&l.removeChild(t._tooltipEl);const p=L(d,r.value);l.appendChild(p),t._tooltipEl=p,t._tooltipArrowEl=p.querySelector(".autotooltip__arrow"),u&&t._tooltipEl?(t.style.textOverflow="ellipsis",T(t,t._tooltipEl,{arrowElement:t._tooltipArrowEl,bindingValue:r.value})):t.style.textOverflow="clip",t._cleanup=n.autoUpdate(t,t._tooltipEl,()=>{t._tooltipEl&&E(t,t._tooltipEl,{arrowElement:t._tooltipArrowEl,bindingValue:r.value})})},t._hideTooltipListener=()=>{t._tooltipEl&&v(t._tooltipEl)},t.addEventListener("mouseenter",t._showTooltipListener),t.addEventListener("mouseleave",t._hideTooltipListener)},o._init(o,i)},inserted(o){o.classList.add("autotooltip--text-truncate")},componentUpdated(o,i){o.style.textOverflow="ellipsis",o._init&&o._init(o,i)},unbind(o){o._tooltipEl&&v(o._tooltipEl),g(o)}};exports.Autotooltip=x;