import{a9 as H,aa as P,av as k,aC as S,aD as G,ac as C,ae as M,a6 as p,aE as R,aF as b,r as m,z as N,aG as W,J as O,s as V,ad as q,aH as D,aI as F,E as J,o as L,c as U,a as Y,G as j,n as T,g as i,l as z,ag as K,aA as Q}from"./index-Cdt4oMy6.js";const X=H({zIndex:{type:P([Number,String]),default:100},target:{type:String,default:""},offset:{type:Number,default:0},position:{type:String,values:["top","bottom"],default:"top"}}),Z={scroll:({scrollTop:o,fixed:c})=>k(o)&&S(c),[G]:o=>S(o)},$="ElAffix",ee=C({name:$}),te=C({...ee,props:X,emits:Z,setup(o,{expose:c,emit:g}){const e=o,h=M("affix"),l=p(),v=p(),s=p(),{height:n}=R(),{height:r,width:x,top:E,bottom:_,update:d}=b(v,{windowScroll:!1}),u=b(l),a=m(!1),w=m(0),f=m(0),A=N(()=>({height:a.value?`${r.value}px`:"",width:a.value?`${x.value}px`:""})),B=N(()=>{if(!a.value)return{};const t=e.offset?W(e.offset):0;return{height:`${r.value}px`,width:`${x.value}px`,top:e.position==="top"?t:"",bottom:e.position==="bottom"?t:"",transform:f.value?`translateY(${f.value}px)`:"",zIndex:e.zIndex}}),y=()=>{if(s.value)if(w.value=s.value instanceof Window?document.documentElement.scrollTop:s.value.scrollTop||0,e.position==="top")if(e.target){const t=u.bottom.value-e.offset-r.value;a.value=e.offset>E.value&&u.bottom.value>0,f.value=t<0?t:0}else a.value=e.offset>E.value;else if(e.target){const t=n.value-u.top.value-e.offset-r.value;a.value=n.value-e.offset<_.value&&n.value>u.top.value,f.value=t<0?-t:0}else a.value=n.value-e.offset<_.value},I=()=>{d(),g("scroll",{scrollTop:w.value,fixed:a.value})};return O(a,t=>g("change",t)),V(()=>{var t;e.target?(l.value=(t=document.querySelector(e.target))!=null?t:void 0,l.value||q($,`Target does not exist: ${e.target}`)):l.value=document.documentElement,s.value=D(v.value,!0),d()}),F(s,"scroll",I),J(y),c({update:y,updateRoot:d}),(t,oe)=>(L(),U("div",{ref_key:"root",ref:v,class:T(i(h).b()),style:z(i(A))},[Y("div",{class:T({[i(h).m("fixed")]:a.value}),style:z(i(B))},[j(t.$slots,"default")],6)],6))}});var ae=K(te,[["__file","affix.vue"]]);const le=Q(ae);export{le as E};