import{D as u,i as l,I as h,V as w,o as y,g as b,l as k,q,r as L}from"./vendor-CI5NvTnj.js";const x={__name:"BaseAnchorWrapper",props:{offsetGap:{type:Number,default:10},id:{type:String,required:!0},tag:{type:String,default:"div"}},setup(r){const f=r,s=u({}),v=u(0),a=u(),d=l(()=>{let e=f.offsetGap;return m.value&&(e+=m.value.offsetHeight),o.value&&(e+=o.value.offsetHeight),e}),o=l(()=>document.querySelector("#js-anchor-links")),m=l(()=>document.querySelector("#js-navbar")),i=()=>{const e=window.innerHeight,n=Math.round((e-d.value)*100/e),t={rootMargin:`${(d.value+1)*-1}px 0px -${n}%`};s.value=new IntersectionObserver(g,t),s.value.observe(a.value),window.addEventListener("resize",p)},g=e=>{for(const n of e){const t=o.value.querySelector(`[href="#${f.id}"]`);n.isIntersecting?t&&t.classList.add("active"):t&&t.classList.remove("active")}},p=()=>{window.requestAnimationFrame?(c(),i()):(clearTimeout(v.value),v.value=setTimeout(()=>{c(),i()},500))},c=()=>{s.value.unobserve(a.value),window.removeEventListener("resize",p)};return h(()=>{o.value&&i()}),w(()=>{o.value&&c()}),(e,n)=>(y(),b(L(r.tag),{id:r.id,ref_key:"el",ref:a},{default:k(()=>[q(e.$slots,"default")]),_:3},8,["id"]))}};export{x as _};