import e from"../_util/classNames.mjs";import t from"../_util/raf.mjs";import n from"../_util/props-util/initDefaultProps.mjs";import{filterEmpty as r,getStyle as i,isFragment as a,isValidElement as o}from"../_util/props-util/index.mjs";import s from"../config-provider/hooks/useConfigInject.mjs";import c from"../_util/vue-types/index.mjs";import{getTransitionName as l}from"../_util/transition.mjs";import{cloneElement as u}from"../_util/vnode.mjs";import d from"../_util/firstNotUndefined.mjs";import f from"../_util/placements.mjs";import p from"../vc-tooltip/index.mjs";import m from"./abstractTooltipProps.mjs";import h from"./style/index.mjs";import{parseColor as g}from"./util.mjs";import{computed as _,createVNode as v,defineComponent as y,ref as b,watch as x}from"vue";var S=(e,t)=>{let n={},r={...e};return t.forEach(t=>{e&&t in e&&(n[t]=e[t],delete r[t])}),{picked:n,omitted:r}},C=()=>({...m(),title:c.any}),w=()=>({trigger:`hover`,align:{},placement:`top`,mouseEnterDelay:.1,mouseLeaveDelay:.1,arrowPointAtCenter:!1,autoAdjustOverflow:!0}),T=y({compatConfig:{MODE:3},name:`ATooltip`,inheritAttrs:!1,props:n(C(),{trigger:`hover`,align:{},placement:`top`,mouseEnterDelay:.1,mouseLeaveDelay:.1,arrowPointAtCenter:!1,autoAdjustOverflow:!0}),slots:Object,setup(n,{slots:c,emit:m,attrs:y,expose:C}){let{prefixCls:w,getPopupContainer:T,direction:E,rootPrefixCls:D}=s(`tooltip`,n),O=_(()=>n.open??n.visible),k=b(d([n.open,n.visible])),A=b(),j;x(O,e=>{t.cancel(j),j=t(()=>{k.value=!!e})});let M=()=>{let e=n.title??c.title;return!e&&e!==0},N=e=>{let t=M();O.value===void 0&&(k.value=!t&&e),t||(m(`update:visible`,e),m(`visibleChange`,e),m(`update:open`,e),m(`openChange`,e))};C({getPopupDomNode:()=>A.value.getPopupDomNode(),open:k,forcePopupAlign:()=>A.value?.forcePopupAlign()});let P=_(()=>{let{builtinPlacements:e,autoAdjustOverflow:t,arrow:r,arrowPointAtCenter:i}=n,a=i;return typeof r==`object`&&(a=r.pointAtCenter??i),e||f({arrowPointAtCenter:a,autoAdjustOverflow:t})}),F=e=>e||e===``,I=e=>{let t=e.type;if(typeof t==`object`&&e.props&&((t.__ANT_BUTTON===!0||t===`button`)&&F(e.props.disabled)||t.__ANT_SWITCH===!0&&(F(e.props.disabled)||F(e.props.loading))||t.__ANT_RADIO===!0&&F(e.props.disabled))){let{picked:t,omitted:n}=S(i(e),[`position`,`left`,`right`,`top`,`bottom`,`float`,`display`,`zIndex`]),r={display:`inline-block`,...t,cursor:`not-allowed`,lineHeight:1,width:e.props&&e.props.block?`100%`:void 0},a=u(e,{style:{...n,pointerEvents:`none`}},!0);return v(`span`,{style:r,class:`${w.value}-disabled-compatible-wrapper`},[a])}return e},L=()=>n.title??c.title?.(),R=(e,t)=>{let n=P.value,r=Object.keys(n).find(e=>n[e].points[0]===t.points?.[0]&&n[e].points[1]===t.points?.[1]);if(r){let n=e.getBoundingClientRect(),i={top:`50%`,left:`50%`};r.includes(`top`)||r.includes(`Bottom`)?i.top=`${n.height-t.offset[1]}px`:(r.includes(`Top`)||r.includes(`bottom`))&&(i.top=`${-t.offset[1]}px`),r.includes(`left`)||r.includes(`Right`)?i.left=`${n.width-t.offset[0]}px`:(r.includes(`right`)||r.includes(`Left`))&&(i.left=`${-t.offset[0]}px`),e.style.transformOrigin=`${i.left} ${i.top}`}},z=_(()=>g(w.value,n.color)),B=_(()=>y[`data-popover-inject`]),[V,H]=h(w,_(()=>!B.value));return()=>{let{openClassName:t,overlayClassName:i,overlayStyle:s,overlayInnerStyle:d}=n,f=r(c.default?.())??null;f=f.length===1?f[0]:f;let m=k.value;if(O.value===void 0&&M()&&(m=!1),!f)return null;let h=I(o(f)&&!a(f)?f:v(`span`,null,[f])),g=e({[t||`${w.value}-open`]:!0,[h.props&&h.props.class]:h.props&&h.props.class}),_=e(i,{[`${w.value}-rtl`]:E.value===`rtl`},z.value.className,H.value),b={...z.value.overlayStyle,...d},x=z.value.arrowStyle,S={...y,...n,prefixCls:w.value,arrow:!!n.arrow,getPopupContainer:T?.value,builtinPlacements:P.value,visible:m,ref:A,overlayClassName:_,overlayStyle:{...x,...s},overlayInnerStyle:b,onVisibleChange:N,onPopupAlign:R,transitionName:l(D.value,`zoom-big-fast`,n.transitionName)};return V(v(p,S,{default:()=>[k.value?u(h,{class:g}):h],arrowContent:()=>v(`span`,{class:`${w.value}-arrow-content`},null),overlay:L}))}}});export{T as default,w as tooltipDefaultProps,C as tooltipProps};