import{d as r,S,U as y,V as h,a3 as f,j as o}from"./ResizeObserver.es.39b48a47.js";import{u}from"./index.dc19bc54.js";const p="_sticky_1yjvp_1",g="_white_1yjvp_6",x="_animationStyle_1yjvp_13";var c={sticky:p,white:g,animationStyle:x},T=r({name:"m-sticky",props:{position:{type:String,default:"top"},mode:{type:String,default:"fixed"},offsetTop:{type:String,default:"0px"},offsetBottom:{default:"0px"},varName:{type:String,default:"--header-height"}},emits:["barHeight"],setup(e,{slots:s,emit:l}){const t=S({divStyle:{},heightV:0,sectionStyle:{width:"100%",height:"auto",minHeight:"auto",left:"0"}}),d=i=>{t.sectionStyle.height=`${i}px`,t.sectionStyle.minHeight=`${i}px`,t.heightV=i,document.documentElement.style.setProperty(e.varName,`${i}px`),l("barHeight",i)},m=y(),a=y();return h(()=>{e.position==="top"?t.divStyle.top=e.offsetTop||"0px":t.divStyle.bottom=e.offsetBottom||"0px";try{u(a.value,i=>{const v=i[0],{height:n}=v.contentRect;Math.abs(n-t.heightV)>1&&setTimeout(()=>{d(n)},10)})}catch{}}),f(()=>e.offsetTop,()=>{t.divStyle.top=e.offsetTop}),f(()=>e.offsetBottom,()=>{t.divStyle.bottom=e.offsetBottom}),()=>o("div",{style:[t.sectionStyle],class:e.mode==="sticky"&&c.sticky},[o("div",{ref:m,class:["van-sticky",e.mode==="fixed"?"van-sticky--fixed":"",c.animationStyle],style:[t.divStyle,t.sectionStyle]},[o("div",{ref:a,style:{position:"relative"}},[s.default&&s.default()])])])}});export{T};