import{aa as S,aZ as P,ab as k,aH as I,t as R,E as $,y as T,z as x,d as B,R as N,ap as O,r as z,D as u,aM as E,N as H,ax as Z,Z as A,a0 as C,c as p,aA as D,an as h,ar as M,x as V}from"./index.28bb778f.js";function _(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[j,F]=R("sticky"),L={zIndex:$,position:T("top"),container:Object,offsetTop:x(0),offsetBottom:x(0)};var U=B({name:j,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(()=>E(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=H(Z(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||D(s))return;const{container:t,position:d}=o,n=h(s),y=M(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.value<n.bottom&&a>c.top,e.transform=m<0?-m:0}else e.fixed=a-i.value<n.bottom}g(y)};return A(()=>e.fixed,t=>l("change",t)),C("scroll",v,{target:f,passive:!0}),_(s,v),()=>{var t;return p("div",{ref:s,style:b.value},[p("div",{class:F({fixed:e.fixed}),style:w.value},[(t=r.default)==null?void 0:t.call(r)])])}}});const G=V(U);export{G as S};
