import{$ as S,a4 as P,a0 as $,a5 as k,x as I,y as T,W as O,a6 as x,d as R,O as B,a7 as N,N as E,Q as u,a8 as z,E as C,a9 as H,Z as V,aa as Z,i as p,ab as _,T as h,ac as j,K as A}from"./index.afa1b71c.js";function D(o,l){if(!S||!window.IntersectionObserver)return;const r=new IntersectionObserver(e=>{l(e[0].intersectionRatio>0)},{root:document.body}),n=()=>{o.value&&r.observe(o.value)},f=()=>{o.value&&r.unobserve(o.value)};P(f),$(f),k(n)}const[F,K]=I("sticky"),L={zIndex:T,position:O("top"),container:Object,offsetTop:x(0),offsetBottom:x(0)};var M=R({name:F,props:L,emits:["scroll","change"],setup(o,{emit:l,slots:r}){const n=B(),f=N(n),e=E({fixed:!1,width:0,height:0,transform:0}),i=u(()=>z(o.position==="top"?o.offsetTop:o.offsetBottom)),b=u(()=>{const{fixed:t,height:d,width:s}=e;if(t)return{width:`${s}px`,height:`${d}px`}}),w=u(()=>{if(!e.fixed)return;const t=C(H(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(!n.value||_(n))return;const{container:t,position:d}=o,s=h(n),y=j(window);if(e.width=s.width,e.height=s.height,d==="top")if(t){const a=h(t),c=a.bottom-i.value-e.height;e.fixed=i.value>s.top&&a.bottom>0,e.transform=c<0?c:0}else e.fixed=i.value>s.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.value<s.bottom&&a>c.top,e.transform=m<0?-m:0}else e.fixed=a-i.value<s.bottom}g(y)};return V(()=>e.fixed,t=>l("change",t)),Z("scroll",v,{target:f}),D(n,v),()=>{var t;return p("div",{ref:n,style:b.value},[p("div",{class:K({fixed:e.fixed}),style:w.value},[(t=r.default)==null?void 0:t.call(r)])])}}});const U=A(M);export{U as S};
