import{c as C,b as E,m as L,t as w,d as B,r as h,bC as R,w as x,bD as N,y as _,Z as y,_ as z,a as r,z as D,$ as b,bE as F,L as H,k as I}from"./index-521a9826.js";import{u as M}from"./use-tab-status-da6d8e9f.js";const[U,o,V]=C("list"),Z={error:Boolean,offset:E(300),loading:Boolean,disabled:Boolean,finished:Boolean,errorText:String,direction:L("down"),loadingText:String,finishedText:String,immediateCheck:w};var $=B({name:U,props:Z,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=h(e.loading),u=h(),g=h(),s=M(),m=R(u),n=()=>{D(()=>{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(m);if(!i.height||F(u))return;let f=!1;const v=b(g);t==="up"?f=i.top-v.top<=l:f=v.bottom-i.bottom<=l,f&&(d.value=!0,c("update:loading",!0),c("load"))})},T=()=>{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(H,{class:o("loading-icon")},{default:()=>[e.loadingText||V("loading")]})])};return x(()=>[e.loading,e.finished,e.error],n),s&&x(s,t=>{t&&n()}),N(()=>{d.value=e.loading}),_(()=>{e.immediateCheck&&n()}),y({check:n}),z("scroll",n,{target:m,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,S(),T(),P(),e.direction==="up"?l:i])}}});const A=I($);export{A as L};