import{Q as E,i as L,l as w,m as B,t as C,d as R,q as g,az as _,x as m,bd as N,E as y,a8 as A,a7 as U,g as o,L as j,aa as T,aD as q,at as z,w as D}from"./index-bc617d61.js";const F=Symbol(),H=()=>E(F,null),[I,r,K]=L("list"),M={error:Boolean,offset:w(300),loading:Boolean,disabled:Boolean,finished:Boolean,errorText:String,direction:B("down"),loadingText:String,finishedText:String,immediateCheck:C};var Q=R({name:I,props:M,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=g(e.loading),u=g(),h=g(),s=H(),x=_(u),n=()=>{j(()=>{if(d.value||e.finished||e.disabled||e.error||(s==null?void 0:s.value)===!1)return;const{direction:t}=e,l=+e.offset,i=T(x);if(!i.height||q(u))return;let f=!1;const v=T(h);t==="up"?f=i.top-v.top<=l:f=v.bottom-i.bottom<=l,f&&(d.value=!0,c("update:loading",!0),c("load"))})},b=()=>{if(e.finished){const t=a.finished?a.finished():e.finishedText;if(t)return o("div",{class:r("finished-text")},[t])}},S=()=>{c("update:error",!1),n()},k=()=>{if(e.error){const t=a.error?a.error():e.errorText;if(t)return o("div",{role:"button",class:r("error-text"),tabindex:0,onClick:S},[t])}},P=()=>{if(d.value&&!e.finished&&!e.disabled)return o("div",{class:r("loading")},[a.loading?a.loading():o(z,{class:r("loading-icon")},{default:()=>[e.loadingText||K("loading")]})])};return m(()=>[e.loading,e.finished,e.error],n),s&&m(s,t=>{t&&n()}),N(()=>{d.value=e.loading}),y(()=>{e.immediateCheck&&n()}),A({check:n}),U("scroll",n,{target:x,passive:!0}),()=>{var t;const l=(t=a.default)==null?void 0:t.call(a),i=o("div",{ref:h,class:r("placeholder")},null);return o("div",{ref:u,role:"feed",class:r(),"aria-busy":d.value},[e.direction==="down"?l:i,P(),b(),k(),e.direction==="up"?l:i])}}});const Y=D(Q);export{Y as L,F as T};
