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