import{j as E,an as w,n as C,v as L,d as B,i as g,aD as R,w as m,_ as N,o as _,aj as j,g as r,y,Y as b,aE as D,a7 as F,ao as H,D as I}from"./index-1fc8de4c.js";import{u as M}from"./use-tab-status-d5f497e5.js";const[U,o,V]=E("list"),Y={error:Boolean,offset:w(300),loading:Boolean,disabled:Boolean,finished:Boolean,errorText:String,direction:C("down"),loadingText:String,finishedText:String,immediateCheck:L};var q=B({name:U,props:Y,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=g(e.loading),u=g(),h=g(),s=M(),v=R(u),n=()=>{y(()=>{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||D(u))return;let f=!1;const x=b(h);t==="up"?f=i.top-x.top<=l:f=x.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(F,{class:o("loading-icon")},{default:()=>[e.loadingText||V("loading")]})])};return m(()=>[e.loading,e.finished,e.error],n),s&&m(s,t=>{t&&n()}),N(()=>{d.value=e.loading}),_(()=>{e.immediateCheck&&n()}),H({check:n}),j("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(),T(),P(),e.direction==="up"?l:i])}}});const G=I(q);export{G as L};
