import{aa as S,aS as P,ab as k,aK as I,t as R,z as T,u as $,w as p,d as B,R as N,am as O,r as z,y as u,ay as C,N as D,aT as E,Z as H,a0 as V,c as x,as as Z,al as h,ao as _,D as j}from"./index.13ca4bcb.js";function A(o,l){if(!S||!window.IntersectionObserver)return;const r=new IntersectionObserver(e=>{l(e[0].intersectionRatio>0)},{root:document.body}),s=()=>{o.value&&r.observe(o.value)},f=()=>{o.value&&r.unobserve(o.value)};P(f),k(f),I(s)}const[F,K]=R("sticky"),L={zIndex:T,position:$("top"),container:Object,offsetTop:p(0),offsetBottom:p(0)};var M=B({name:F,props:L,emits:["scroll","change"],setup(o,{emit:l,slots:r}){const s=N(),f=O(s),e=z({fixed:!1,width:0,height:0,transform:0}),i=u(()=>C(o.position==="top"?o.offsetTop:o.offsetBottom)),b=u(()=>{const{fixed:t,height:d,width:n}=e;if(t)return{width:`${n}px`,height:`${d}px`}}),w=u(()=>{if(!e.fixed)return;const t=D(E(o.zIndex),{width:`${e.width}px`,height:`${e.height}px`,[o.position]:`${i.value}px`});return e.transform&&(t.transform=`translate3d(0, ${e.transform}px, 0)`),t}),g=t=>l("scroll",{scrollTop:t,isFixed:e.fixed}),v=()=>{if(!s.value||Z(s))return;const{container:t,position:d}=o,n=h(s),y=_(window);if(e.width=n.width,e.height=n.height,d==="top")if(t){const a=h(t),c=a.bottom-i.value-e.height;e.fixed=i.value>n.top&&a.bottom>0,e.transform=c<0?c:0}else e.fixed=i.value>n.top;else{const{clientHeight:a}=document.documentElement;if(t){const c=h(t),m=a-c.top-i.value-e.height;e.fixed=a-i.valuec.top,e.transform=m<0?-m:0}else e.fixed=a-i.valuee.fixed,t=>l("change",t)),V("scroll",v,{target:f,passive:!0}),A(s,v),()=>{var t;return x("div",{ref:s,style:b.value},[x("div",{class:K({fixed:e.fixed}),style:w.value},[(t=r.default)==null?void 0:t.call(r)])])}}});const q=j(M);export{q as S};