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