UNPKG

mongoku

Version:

[![CI](https://github.com/huggingface/Mongoku/actions/workflows/ci.yml/badge.svg)](https://github.com/huggingface/Mongoku/actions/workflows/ci.yml)

2 lines (1 loc) 2.01 kB
import{f as O,a as A}from"./DaMh_eeB.js";import{a9 as R,j as C,p as j,b as g,a8 as k,a1 as x,g as t,O as z,d as u,f as G,c as T,r as E,s as I,a as N,t as S}from"./IwGwbOe7.js";import{e as y}from"./BDGd1aqF.js";import{s as B}from"./BUO1EOQu.js";import{p as H,i as Y}from"./CCOVnadf.js";import{a as q,p as D}from"./CKvueigk.js";import{t as F,s as J}from"./DqxUmOYD.js";import{b as M}from"./CkMoyTwc.js";function m(o,e={},n,l){for(var i in n){var s=n[i];e[i]!==s&&(n[i]==null?o.style.removeProperty(i):o.style.setProperty(i,s,l))}}function K(o,e,n,l){var i=o[R];if(C||i!==e){var s=F(e,l);(!C||s!==o.getAttribute("style"))&&(s==null?o.removeAttribute("style"):o.style.cssText=s),o[R]=e}else l&&(Array.isArray(l)?(m(o,n?.[0],l[0]),m(o,n?.[1],l[1],"important")):m(o,n,l));return l}var Q=O('<div role="tooltip"><!></div>'),U=O('<div class="relative inline-block"><!></div><!>',1);function rt(o,e){j(e,!0);let n=H(e,"show",3,!1),l=H(e,"tooltipClass",3,""),i=g(void 0),s=g(void 0),f=g(k({left:"",right:"",top:""}));x(()=>{n()&&t(i)&&t(s)&&z().then(()=>{if(!t(s)||!t(i))return;const r=t(s).getBoundingClientRect(),a=t(i).getBoundingClientRect(),c=window.innerWidth,h=window.innerHeight;u(f,{left:"",right:"",top:""},!0),r.left+a.width>c?t(f).right=`${c-r.right}px`:t(f).left=`${r.left}px`;const w=h-r.bottom,W=r.top,d=5;w>=a.height+d||w>W?t(f).top=`${r.bottom+d}px`:t(f).top=`${r.top-a.height-d}px`})});var b=U(),v=G(b),P=T(v);B(P,()=>e.trigger),E(v),M(v,r=>u(s,r),()=>t(s));var _=I(v);{var L=r=>{var a=Q();let c;var h=T(a);B(h,()=>e.content),E(a),q(a,p=>D?.(p)),M(a,p=>u(i,p),()=>t(i)),S(()=>{J(a,1,`fixed bg-[var(--light-background)] border border-[var(--border-color)] rounded-2xl z-[1000] shadow-xl backdrop-blur-md ${l()??""}`),c=K(a,"color: var(--text);",c,{left:t(f).left,right:t(f).right,top:t(f).top})}),y("mouseenter",a,function(...p){e.onTooltipMouseEnter?.apply(this,p)}),y("mouseleave",a,function(...p){e.onTooltipMouseLeave?.apply(this,p)}),A(r,a)};Y(_,r=>{n()&&r(L)})}A(o,b),N()}export{rt as T,K as s};