import{j as w,am as C,n as E,v as L,d as B,i as g,aK as R,w as x,_ as N,o as _,ai as y,g as r,y as j,Y as T,aT as D,a9 as F,an as H,D as I}from"./index-e362c2e8.js";import{u as K}from"./use-tab-status-92e284d0.js";const[M,o,U]=w("list"),V={error:Boolean,offset:C(300),loading:Boolean,disabled:Boolean,finished:Boolean,errorText:String,direction:E("down"),loadingText:String,finishedText:String,immediateCheck:L};var Y=B({name:M,props:V,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=g(e.loading),u=g(),h=g(),s=K(),v=R(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(v);if(!i.height||D(u))return;let f=!1;const m=T(h);t==="up"?f=i.top-m.top<=l:f=m.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 r("div",{class:o("finished-text")},[t])}},k=()=>{c("update:error",!1),n()},P=()=>{if(e.error){const t=a.error?a.error():e.errorText;if(t)return r("div",{role:"button",class:o("error-text"),tabindex:0,onClick:k},[t])}},S=()=>{if(d.value&&!e.finished&&!e.disabled)return r("div",{class:o("loading")},[a.loading?a.loading():r(F,{class:o("loading-icon")},{default:()=>[e.loadingText||U("loading")]})])};return x(()=>[e.loading,e.finished,e.error],n),s&&x(s,t=>{t&&n()}),N(()=>{d.value=e.loading}),_(()=>{e.immediateCheck&&n()}),H({check:n}),y("scroll",n,{target:v,passive:!0}),()=>{var t;const l=(t=a.default)==null?void 0:t.call(a),i=r("div",{ref:h,class:o("placeholder")},null);return r("div",{ref:u,role:"feed",class:o(),"aria-busy":d.value},[e.direction==="down"?l:i,S(),b(),P(),e.direction==="up"?l:i])}}});const A=I(Y);export{A as L};