import{aa as S,aZ as P,ab as k,aH as I,t as R,z as $,u as T,w as p,d as B,R as N,ap as O,r as z,y as u,aM as H,N as Z,ax as A,Z as C,a0 as D,c as x,aA as E,an as h,ar as M,D as V}from"./index.3b0304e1.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:p(0),offsetBottom:p(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(()=>H(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=Z(A(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||E(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.valuec.top,e.transform=m<0?-m:0}else e.fixed=a-i.valuee.fixed,t=>l("change",t)),D("scroll",v,{target:f,passive:!0}),_(s,v),()=>{var t;return x("div",{ref:s,style:b.value},[x("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};