"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),h=require("../_util/classNames.js"),q=require("../_util/props-util/initDefaultProps.js"),k=require("../_util/type.js"),P=require("../config-provider/hooks/useConfigInject.js"),j=require("./context.js"),g=()=>({prefixCls:String,href:String,title:k.anyType(),target:String,customTitleProps:k.objectType()}),x=e.defineComponent({compatConfig:{MODE:3},name:"AAnchorLink",inheritAttrs:!1,props:q.default(g(),{href:"#"}),slots:Object,setup(t,{slots:c,attrs:s}){let r=null;const{handleClick:m,scrollTo:p,unregisterLink:a,registerLink:u,activeLink:C}=j.useInjectAnchor(),{prefixCls:v}=P.default("anchor",t),T=n=>{const{href:i}=t;m(n,{title:r,href:i}),p(i)};return e.watch(()=>t.href,(n,i)=>{e.nextTick(()=>{a(i),u(n)})}),e.onMounted(()=>{u(t.href)}),e.onBeforeUnmount(()=>{a(t.href)}),()=>{const{href:n,target:i,title:l=c.title,customTitleProps:f={}}=t,o=v.value;r=typeof l=="function"?l(f):l;const d=C.value===n,y=h.default(`${o}-link`,{[`${o}-link-active`]:d},s.class),L=h.default(`${o}-link-title`,{[`${o}-link-title-active`]:d});return e.createVNode("div",{...s,class:y},[e.createVNode("a",{class:L,href:n,title:typeof r=="string"?r:"",target:i,onClick:T},[c.customTitle?c.customTitle(f):r]),c.default?.()])}}});exports.anchorLinkProps=g;exports.default=x;
