import{d as m,x as r,r as d,y as v,Z as u,w as n,a as o}from"./index-971588a5.js";const h="_sticky_4d2w6_1",S="_white_4d2w6_6",x={sticky:h,white:S},k=m({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(t,{slots:s,emit:c}){const e=r({divStyle:{},heightV:0,sectionStyle:{width:"100%",height:"auto",left:"0"}}),y=i=>{e.sectionStyle.height=`${i}px`,e.heightV=i,document.documentElement.style.setProperty(t.varName,`${i}px`),c("barHeight",i)},f=d(),a=d();return v(()=>{t.position==="top"?e.divStyle.top=t.offsetTop||"0px":e.divStyle.bottom=t.offsetBottom||"0px",new ResizeObserver(()=>{const{height:l}=u(a.value);y(l)}).observe(f.value)}),n(()=>t.offsetTop,()=>{e.divStyle.top=t.offsetTop}),n(()=>t.offsetBottom,()=>{e.divStyle.bottom=t.offsetBottom}),()=>o("div",{style:[e.sectionStyle],class:t.mode==="sticky"&&x.sticky},[o("div",{ref:f,class:["van-sticky",t.mode==="fixed"?"van-sticky--fixed":""],style:[e.divStyle,e.sectionStyle]},[o("div",{ref:a},[s.default&&s.default()])])])}});export{k as M};
