import{d as h,a0 as d,c as e}from"./ResizeObserver.es.7b3c8c20.js";import{u as n}from"./index.601919da.js";const r="_sticky_1s8d5_1",a="_white_1s8d5_6";var s={sticky:r,white:a,"white-only":"_white-only_1s8d5_13"},y=h({emits:["getHeight"],name:"o-sticky",props:{position:{type:String,default:"top"},background:{type:String,default:""},mode:{type:String,default:"fixed"},offsetTop:{type:String,default:"0px"},offsetBottom:{default:"0px"},varName:{type:String,default:"--header-height"}},data(){return{divStyle:{},heightV:0,sectionStyle:{width:"100%",height:"auto",left:"0"}}},mounted(){this.position==="top"?this.divStyle.top=this.offsetTop||"0px":this.divStyle.bottom=this.offsetBottom||"0px";try{n(this.$refs.div2,t=>{const o=t[0],{height:i}=o.contentRect;Math.abs(i-this.heightV)>1&&setTimeout(()=>{this.__initHeight(i)},10)})}catch(t){console.log(t,"error useResizeObserver")}d(()=>{})},methods:{__initHeight(t){this.sectionStyle.height=`${t}px`,this.heightV=t,document.documentElement.style.setProperty(this.varName,`${t}px`),this.$emit("getHeight",t)}},watch:{offsetTop(){this.divStyle.top=this.offsetTop},offsetBottom(){this.divStyle.bottom=this.offsetBottom}},render(){return e("div",{style:[this.sectionStyle],class:this.mode==="sticky"&&s.sticky},[e("div",{ref:"div",class:["van-sticky",this.mode==="fixed"?"van-sticky--fixed":"",s[this.background]],style:[this.divStyle,this.sectionStyle]},[e("div",{ref:"div2"},[this.$slots.default&&this.$slots.default()])])])}});export{y as O};