"use strict";const o=require("vue"),p=require("./index-DCccP2Kt.cjs");function y({tooltip:e,chart:r,clientPosition:t,positionPreference:l="center",defaultOffsetY:a=24,blockShiftY:d=!1}){const n=o.ref(0),s=o.ref(a);if(e&&r){const{width:u,height:c}=e.getBoundingClientRect(),{right:i,left:f,bottom:v}=r.getBoundingClientRect();l==="center"&&(t.x+u/2>i?n.value=-u+(i-t.x):t.x-u/2<f?n.value=-u+(u-(t.x-f)):n.value=-u/2),l==="right"&&(t.x+u>i?n.value=-u+(i-t.x):n.value=0),l==="left"&&(t.x<f+u?n.value=-u+(u-(t.x-f)):n.value=-u),t.y+c>v&&!d&&(s.value=-c-a)}return{top:t.y+s.value,left:t.x+n.value}}function b(e,r,t){o.onMounted(()=>e.addEventListener(r,t)),o.onUnmounted(()=>e.removeEventListener(r,t))}function m(){const e=o.ref(0),r=o.ref(0);return b(window,"mousemove",t=>{e.value=t.clientX,r.value=t.clientY}),{x:e,y:r}}const g=["innerHTML"],x={__name:"Tooltip",props:{backgroundColor:{type:String,default:"#FFFFFF"},color:{type:String,default:"#000000"},content:String,maxWidth:{type:String,default:"300px"},parent:{type:Object},show:{type:Boolean,default:!1},isCustom:{type:Boolean,default:!1},fontSize:{type:[Number,String],default:14},borderRadius:{type:Number,default:4},borderColor:{type:String,default:"#e1e5e8"},borderWidth:{type:Number,default:1},backgroundOpacity:{type:Number,default:100},position:{type:String,default:"center"},offsetY:{type:Number,default:24},blockShiftY:{type:Boolean,default:!1}},setup(e){const r=e,t=o.ref(null),l=o.ref(m()),a=o.computed(()=>y({tooltip:t.value,chart:r.parent,clientPosition:l.value,positionPreference:r.position,defaultOffsetY:r.offsetY,blockShiftY:r.blockShiftY})),d=o.computed(()=>p.setOpacity(r.backgroundColor,r.backgroundOpacity));return(n,s)=>e.show?(o.openBlock(),o.createElementBlock("div",{key:0,ref_key:"tooltip",ref:t,class:o.normalizeClass({"vue-data-ui-custom-tooltip":e.isCustom,"vue-data-ui-tooltip":!e.isCustom}),style:o.normalizeStyle(`pointer-events:none;top:${a.value.top}px;left:${a.value.left}px;${e.isCustom?"":`background:${d.value};color:${e.color};max-width:${e.maxWidth};font-size:${e.fontSize}px`};border-radius:${e.borderRadius}px;border:${e.borderWidth}px solid ${e.borderColor};`)},[o.renderSlot(n.$slots,"tooltip-before"),o.renderSlot(n.$slots,"default"),o.createElementVNode("div",{innerHTML:e.content},null,8,g),o.renderSlot(n.$slots,"tooltip-after")],6)):o.createCommentVNode("",!0)}};exports._sfc_main=x;exports.useMouse=m;
