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